1.Error message
Operation not allowed after resultset closed
2.Why does resultset close automatically
The key to the error is: one stmt has multiple rs to operate
The correct operation should be: the RS1 obtained from stmt must be operated immediately before the other RS2 can be obtained, and then the RS2 can be operated. It cannot be used alternately; Or use different stmt instead of rs
The error code is as follows:
stmt = conn.createstatement()
rs=stmt.executeQuery(“select * from t1”);
rst=stmt.executeQuery(“select * from t2”);
rs.last();// Since RST = stmt. ExecuteQuery (SQL_ a); RS will be shut down! So when the program is executed here, it will prompt that resultset has been closed. The error message is: Java. SQL. Sqlexception: operation not allowed after resultset closed
rst. Last()
correct code:
stmt = conn.createstatement()
rs=stmt.executeQuery(“select * from t1”);
rs.last();// The operation of RS should be done immediately. After the operation, RST is obtained from the database, and then RST is operated
RST = stmt. ExecuteQuery (“select * from T2”)
rst.last();