After upgrading the JDBC driver from the Legacy JDBC Type 2 driver (db2java.zip) to the Data Server Driver for JDBC (db2jcc.jar) the following error now occurs "Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null"
com.ibm.db2.jcc.am.SqlException: [jcc][t4] [4.11.77] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null
The IBM Data Server Driver for JDBC and SQLJ automatically closes the cursor when all rows have been retrieved from a ResultSet. When ResultSet.next is executed after the cursor is closed the SQLException is thrown. This behavior differs from the DB2 JDBC Type 2 drive where the cursor is not automatically closed upon retrieving all rows from a ResultSet.
Resolving the problem
Modify the application code to avoid calling ResultSet.next after all rows have been retrieved.
Alternatively, it is possible to workaround the issue by enabling the allowNextOnExhaustedResultSet datasource property. With the allowNextOnExhaustedResultSet property set to DB2BaseDataSource.YES (1), and a forward-only cursor is positioned after the last row of a result set, a call to ResultSet.next returns false instead of throwing an SQLException.
For further discussion on this topic, visit this developerWorks forum thread:
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.