Sunday, 8 September 2013

mutiple query with jdbc

mutiple query with jdbc

I want to use two queries from the same database but I get the error:
java.sql.SQLException: After end of result set
How do I avoid this problem? Note that every table doesn't have same rows
number.
Code:
try {
Dbconnection NewConnect = new Dbconnection();
Dbconnection NewConnect2 = new Dbconnection();
Connection con = NewConnect.MakeConnect();
Connection con2 = NewConnect2.MakeConnect();
Statement stmt = con.createStatement();
Statement stmt2 = con2.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * from class");
ResultSet rs2 = stmt2.executeQuery("SELECT * from intervals");
while (rs.next()) {
clasess.add(rs.getString(2));
}
while (rs2.next()) {
intervals.add(rs.getString(2));
}
} catch (Exception ex) {
System.out.println(ex);
}

No comments:

Post a Comment