pentaho/pentaho-kettle · error · KettleDatabaseException

Error closing resultset after getting schemas!

Error message

Error closing resultset after getting schemas!

What it means

Thrown in the finally block of getSchemas() when the catalog ResultSet cannot be closed after reading schemas. The schema listing may have succeeded, but cleanup failed — usually a broken connection or driver cursor-close failure. Wrapped as KettleDatabaseException.

Solutions

  1. Ensure the connection is alive before metadata reads; reconnect if checkConnection() fails.
  2. Use a dedicated Database per thread instead of sharing one instance.
  3. Raise firewall/DB idle timeouts for long-running jobs.
  4. Inspect the chained SQLException cause to pinpoint the driver failure.

Example fix

// before
db.getSchemas(); // on a connection idle for hours

// after
if (!db.checkConnection()) { db.disconnect(); db.connect(); }
db.getSchemas();
Defensive patterns

Strategy: try-catch

Validate before calling

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

Try / catch

try {
  schemas = db.getSchemas();
} catch (KettleDatabaseException e) {
  log.warn("Schema resultset close failed: " + e.getCause());
  db.disconnect(); db.connect();
}

Prevention

When it happens

Trigger: Database.getSchemas() where catalogResultSet is non-null but close() throws SQLException — connection dropped between iteration and close, driver cursor invalidated, or concurrent connection use.

Common situations: DB session killed during schema listing; network/firewall idle timeout; driver bug closing cursors after a partial metadata failure; sharing the Database object across threads.

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/64626a4245a36c55. Report an issue: GitHub.

Appendix: source

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

  public String[] getSchemas() throws KettleDatabaseException {
    ArrayList<String> catalogList = new ArrayList<>();
    ResultSet catalogResultSet = null;
    try {
      catalogResultSet = databaseMeta.getSchemas( getDatabaseMetaData() );
      // Grab all the catalog names and put them in an array list
      while ( catalogResultSet != null && catalogResultSet.next() ) {
        catalogList.add( catalogResultSet.getString( 1 ) );
      }
    } catch ( SQLException e ) {
      throw new KettleDatabaseException( "Error getting schemas!", e );
    } finally {
      try {
        if ( catalogResultSet != null ) {
          catalogResultSet.close();
        }
      } catch ( SQLException e ) {
        throw new KettleDatabaseException( "Error closing resultset after getting schemas!", e );
      }
    }

    if ( log.isDetailed() ) {
      log.logDetailed( "read :" + catalogList.size() + " schemas from db meta-data." );
    }

    return catalogList.toArray( new String[ catalogList.size() ] );
  }

  public String[] getCatalogs() throws KettleDatabaseException {
    ArrayList<String> catalogList = new ArrayList<>();
    ResultSet catalogResultSet = null;
    try {
      catalogResultSet = getDatabaseMetaData().getCatalogs();
      // Grab all the catalog names and put them in an array list
      while ( catalogResultSet != null && catalogResultSet.next() ) {
        catalogList.add( catalogResultSet.getString( 1 ) );

View on GitHub (pinned to f3058517a1)