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();
Similar Posts:
- [Solved] Operation not allowed after ResultSet closed
- [Solved] JAVA:java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcodbcDrive
- HttpURLConnection Cannot write output after reading input.
- DB2 Database table operation error SQL0668N Operation not allowed for reason code “1” on table “db”. S…
- SQL0668N Operation not allowed for reason code “3” on table “TEST”. SQLSTAT…
- Pdostation:: bindparam vs bindvalue of PHP extension PDO MySQL
- Linux Programmer Error: /bin/bash: No such file or directory [How to Solve]
- Server returned HTTP response code: 500 for URL xxxxxxxxxxxxx
- Java.sql.sqlexception: an analysis of the causes of exhausted resultset
- Session_start(): Cannot start session when headers already sent in [How to Solve]