我想使用来自同一个数据库的两个查询,但出现错误:
java.sql.SQLException:结果集结束后
我该如何避免这个问题?请注意,每个表都没有相同的行号。
代码:
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);
}