Topic
2 replies Latest Post - ‏2014-10-19T18:48:39Z by HunterMedney
amccarl
amccarl
73 Posts
ACCEPTED ANSWER

Pinned topic Invalid operation: result set is closed

‏2013-06-11T19:47:01Z |

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". 

This occurs because 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.

To resolve 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.

 

This is also covered by the technical article 1461670http://www.ibm.com/support/docview.wss?uid=swg21461670

 

Updated on 2013-06-14T14:40:10Z at 2013-06-14T14:40:10Z by amccarl
  • amccarl
    amccarl
    73 Posts
    ACCEPTED ANSWER

    Re: Invalid operation: result set is closed

    ‏2013-06-14T14:27:22Z  in response to amccarl
    Hello!  We've had a number of clients respond through feedback to our technical documents indicating that they have further questions or comments that require additional dialogue.  Unfortunately, our feedback is anonymous, so unless an email address or other contact information is included, we have no way to get back in touch with you.
     
    Within DB2 support, the management team asked if we could somehow link our documents to the forums so that we could invite more discussion - like this!   As a start, we chose about 30 technical articles and "seeded" the forum with initial entries so that we could have a starting place for conversation.  The documents have now been updated with links to the forums as well.  
     
    Hopefully, we will make DB2 support better by providing more interaction around our technical information!
     
  • HunterMedney
    HunterMedney
    1 Post
    ACCEPTED ANSWER

    Unclear how to know when all rows have been retrieved

    ‏2014-10-19T18:48:39Z  in response to amccarl

    I've looked at the tech note and the referenced pages in the product documentation, and I'm unclear how to code for this behavior.  Calling rs.next() and using the false return value as the basis to know whether more rows exist is the only method I've seen to retrieve records from a query.  Can you provide a code snippet on how a JDBC call would work under the behavior described in the tech note?