pentaho/pentaho-kettle · error · KettleDatabaseException
Error closing resultset after getting views from schema []
Error message
Error closing resultset after getting views from schema []
What it means
Thrown by Database.getTableMetaData-style schema table/view enumeration when the JDBC ResultSet holding the view names cannot be closed in the finally block. The view listing itself may have succeeded, but cleanup failed, so Kettle wraps the SQLException in a KettleDatabaseException. It usually indicates a broken connection or driver-level cursor close failure.
Solutions
- Check/verify the DB connection is still alive before metadata calls (connection healthy, not timed out).
- Ensure only one thread uses the Database instance; synchronize or create one Database per thread.
- Increase firewall/idle timeout or enable JDBC keepalive so the connection survives metadata queries.
- Upgrade the JDBC driver; some drivers throw on closing already-invalidated cursors.
Example fix
// before
Database db = new Database(meta);
db.connect();
List<String> views = db.getViews(false, null); // later, connection already stale
// after
Database db = new Database(meta);
db.connect();
if (!db.checkConnection()) { db.disconnect(); db.connect(); }
List<String> views = db.getViews(false, null); 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 {
views = db.getViews(false, schema);
} catch (KettleDatabaseException e) {
log.warn("View metadata read/close failed, reconnecting: " + e.getMessage());
db.disconnect(); db.connect();
views = db.getViews(false, schema);
} Prevention
- Verify connection liveness before long metadata operations
- Never share a Database object across threads
- Keep JDBC drivers up to date
- Configure DB/firewall idle timeouts larger than job duration
When it happens
Trigger: Calling Database.getViews(...)/getTableMap-style metadata enumeration where connection.alltables (the ResultSet from getDatabaseMetaData().getTables) is non-null but rs.close() throws SQLException — typically because the connection was already closed or the driver dropped it.
Common situations: Connection killed by firewall/DB timeout before metadata reads finish; Oracle/MySQL driver cursor close failure on stale connections; concurrent use of one Database connection from multiple threads; calling getViews after disconnect().
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
- Error closing resultset after getting catalogs!
- Error closing resultset after getting schemas!
- Error closing resultset after getting synonyms from schema…
- Couldn't close query: resultset or prepared statements
- Database.Exception.EmptyConnectionError
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/d655fc84d27eabc6.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:4288
if ( tableProperty.equals( propValue ) ) {
multimapPut( schema, table, tableMap );
}
}
}
} else {
multimapPut( schema, table, tableMap );
}
}
} catch ( SQLException e ) {
log.logError( "Error getting tablenames from schema [" + schemaname + "]" );
} finally {
try {
if ( alltables != null ) {
alltables.close();
}
} catch ( SQLException e ) {
throw new KettleDatabaseException( "Error closing resultset after getting views from schema ["
+ schemaname + "]", e );
}
}
if ( log.isDetailed() ) {
log.logDetailed( "read :" + multimapSize( tableMap ) + " table names from db meta-data." );
}
return tableMap;
}
public String[] getViews() throws KettleDatabaseException {
return getViews( false );
}
public String[] getViews( boolean includeSchema ) throws KettleDatabaseException {
return getViews( null, includeSchema );
}View on GitHub (pinned to f3058517a1)