Uploaded image for project: 'GeoTools'
  1. GEOT-5643

DB2 online tests fail with "Invalid operation: result set is closed"


    • Type: Bug
    • Status: Resolved
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: 16.1
    • Fix Version/s: 17-beta
    • Component/s: jdbc, jdbc-db2 plugin
    • Labels:
    • Environment:

      Most likely all environments


      A number of tests are failing due to the way result sets are handled in DB2 vs other databases like PostGIS.

      This problem will occur in any application using DB2 and a FeatureWriter to insert new features.

      For example in JDBCDataStoreOnlineTest::testCreateSchemaWithConstraints, there is logic

      //grab a writer
      try(FeatureWriter<SimpleFeatureType, SimpleFeature> w =
      dataStore.getFeatureWriter( tname("ft2"),Transaction.AUTO_COMMIT)) {

      SimpleFeature f = w.next();
      f.setAttribute( 1, new Integer(0));
      f.setAttribute( 2, "hello");

      This fails on w.next() with

      java.io.IOException: com.ibm.db2.jcc.am.SqlException: [jcc][t4][10120][10898][3.66.46] Invalid operation: result set is closed. ERRORCODE=-4470, SQLSTATE=null

      which results from:
      ResultSetFeature rsf = getOrCreateRSF();

      which tried to get the metadata from the result set. DB2 closes the result set when the end of the data is reached and fails when attempting to get the metadata on a closed result set. PostGIS still can get the metadata on a result set that is closed.

      Apparently JDBC is not definitive on what should happen when the end of a result set is reached.

      The proposed fix is to get and save the metadata for the FeatureSource in the constructors for JDBCInsertFeatureWriter and JDBCUpdateFeatureWriter. The instance variable to save the metadata should be defined in JDBCFeatureReader so that it is available in subclasses.

      This should also have a slight performance advantage in that the metadata is only retrieved once if multiple features are written, although the time to get the metadata is probably small compared to the time to insert a row into the database.




            • Assignee:
              dadler David Adler
            • Votes:
              0 Vote for this issue
              2 Start watching this issue


              • Created: