`
import java.sql.*; public class Match { public static void main(String args[]) throws Exception{ DBConnection1 con = new DBConnection1(); DBConnection con1 = new DBConnection(); Connection conn = null,conn1=null; conn = con.getConnection(); conn1 = con1.getConnection(); Statement st = null; PreparedStatement pst = null; ResultSet rs = null,rs1 = null; st = conn.createStatement(); String query1 = "SELECT Name FROM Employee WHERE Name=?"; pst = conn1.prepareStatement(query1); st.setFetchSize(Integer.MIN_VALUE); String query = "SELECT name FROM emp"; rs = st.executeQuery(query); String name = ""; int count = 0; while(rs.next()){ title = rs.getString("name"); pst.setString(1, title); rs1 = pst.executeQuery(); while(rs1.next()){ count++; if(count % 100 == 0) System.out.println(count); } } System.out.println(count); } } `
I am selecting value from the very large database based on some value from other database . I am running my select query in a while loop. After running my java code after getting many result , i am getting
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:Communications link failure exception. I have no idea why this is happening. If you guys have any idea please help
I already read the old questions based on this exception but none of them helps.