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
Ensure the connection has not been closed prematurely. 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:
Was this topic helpful?
16 June 2018