pentaho/pentaho-kettle · error · KettleDatabaseException

Error closing resultset after getting synonyms from schema…

Error message

Error closing resultset after getting synonyms from schema []

What it means

Thrown in the finally block of the synonym enumeration when the JDBC ResultSet cannot be closed. The synonym listing may have completed, but cursor cleanup failed, indicating a broken connection or driver cursor-close failure. Wrapped as KettleDatabaseException.

Solutions

  1. Reconnect (checkConnection/disconnect+connect) before metadata calls on long-lived Database objects.
  2. Avoid sharing one Database instance across threads; use one per thread.
  3. Check DB/network logs for session drops (firewall, listener) and raise idle timeouts.
  4. Inspect the chained SQLException cause to identify the driver-level failure.

Example fix

// before
List<String> syns = db.getSynonyms(false, schema); // long idle gap before call

// after
if (!db.checkConnection()) { db.disconnect(); db.connect(); }
List<String> syns = db.getSynonyms(false, schema);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!db.checkConnection()) { db.disconnect(); db.connect(); }

Type guard

boolean connectionAlive(Database db) { return db != null && db.getConnection() != null; }

Try / catch

try {
  synonyms = db.getSynonyms(false, schema);
} catch (KettleDatabaseException e) {
  log.warn("Synonym resultset close failed, reconnecting: " + e.getMessage());
  db.disconnect(); db.connect();
}

Prevention

When it happens

Trigger: Database.getSynonyms(...) where alltables ResultSet is non-null but close() throws SQLException — stale/dropped connection, driver cursor invalidation after a metadata error, or concurrent use of the connection.

Common situations: Oracle session killed mid metadata query; connection idle-timeout during long synonym scans; calling synonyms after an earlier SQLException already invalidated the driver's cursor state.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/cb5a2032f2c3a7ff. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:4478

        }

        String table = alltables.getString( TABLES_META_DATA_TABLE_NAME );

        if ( log.isRowLevel() ) {
          log.logRowlevel( toString(), "got synonym from meta-data: "
            + databaseMeta.getQuotedSchemaTableCombination( schema, table ) );
        }
        multimapPut( schema, table, synonymMap );
      }
    } catch ( SQLException e ) {
      throw new KettleDatabaseException( "Error getting synonyms from schema [" + schemaname + "]", e );
    } finally {
      try {
        if ( alltables != null ) {
          alltables.close();
        }
      } catch ( SQLException e ) {
        throw new KettleDatabaseException( "Error closing resultset after getting synonyms from schema ["
          + schemaname + "]", e );
      }
    }

    if ( log.isDetailed() ) {
      log.logDetailed( "read :" + multimapSize( synonymMap ) + " synonyms from db meta-data." );
    }

    return synonymMap;
  }

  private <K, V> void multimapPut( final K key, final V value, final Map<K, Collection<V>> map ) {
    Collection<V> valueCollection = map.get( key );
    if ( valueCollection == null ) {
      valueCollection = new HashSet<>();
    }
    valueCollection.add( value );
    map.put( key, valueCollection );

View on GitHub (pinned to f3058517a1)