pentaho/pentaho-kettle · error · KettleDatabaseException
Unable to retrieve metadata from resultset
Error message
Unable to retrieve metadata from resultset
What it means
Thrown in Database.getRow(ResultSet, boolean) when rs.getMetaData() throws SQLException while lazily initializing the cached rowMeta. The library caches row metadata on first getRow call; failure to fetch it blocks all subsequent row reads.
Solutions
- Check the connection is valid (isValid/ping) before executing and reading
- Inspect the chained SQLException cause for the driver's reason
- Re-execute the query to obtain a fresh result set
- Upgrade the JDBC driver if getMetaData() fails on valid result sets
Example fix
// before
Object[] row = db.getRow(rs, false);
// after
if (!rs.isClosed() && conn.isValid(5)) {
Object[] row = db.getRow(rs, false);
} else {
rs = stmt.executeQuery(sql); // re-acquire
} Defensive patterns
Strategy: try-catch
Validate before calling
if (rs.isClosed() || !conn.isValid(5)) {
rs = stmt.executeQuery(sql); // re-acquire before reading
} Type guard
null
Try / catch
try {
row = db.getRow(rs, false);
} catch (KettleDatabaseException e) {
if (e.getMessage().contains("Unable to retrieve metadata")) {
rs = stmt.executeQuery(sql); // retry with fresh result set
} else { throw e; }
} Prevention
- Read rows promptly after executing the query
- Apply connection keep-alive/validity checks for long jobs
- Avoid closing statements from other threads mid-read
- Re-execute rather than reusing stale result sets
When it happens
Trigger: First call to Database.getRow(rs, lazyConversion) on a result set whose metadata cannot be retrieved — result set closed, connection dropped, or driver error on getMetaData().
Common situations: Long-running reads where the connection timed out before the first getRow; result set closed by another thread; driver bugs after executing large or complex queries.
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
- MySQLDatabaseMeta.Exception.LegacyColumnNameNoRSMetaDataException
- MySQLDatabaseMeta.Exception.LegacyColumnNameException
- No result set metadata available to retrieve row metadata!
- Cannot fetch driver metadata for
- Couldn't close query: resultset or prepared statements
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/f2e4f499d21e7178.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:2996
*/
public Object[] getRow( ResultSet rs ) throws KettleDatabaseException {
return getRow( rs, false );
}
/**
* Get a row from the resultset.
*
* @param rs The resultset to get the row from
* @param lazyConversion set to true if strings need to have lazy conversion enabled
* @return one row or null if no row was found on the resultset or if an error occurred.
*/
public Object[] getRow( ResultSet rs, boolean lazyConversion ) throws KettleDatabaseException {
if ( rowMeta == null ) {
ResultSetMetaData rsmd = null;
try {
rsmd = rs.getMetaData();
} catch ( SQLException e ) {
throw new KettleDatabaseException( "Unable to retrieve metadata from resultset", e );
}
rowMeta = getRowInfo( rsmd, false, lazyConversion );
}
return getRow( rs, null, rowMeta );
}
/**
* Get a row from the resultset.
*
* @param rs The resultset to get the row from
* @return one row or null if no row was found on the resultset or if an error occurred.
*/
public Object[] getRow( ResultSet rs, ResultSetMetaData dummy, RowMetaInterface rowInfo )
throws KettleDatabaseException {
long startTime = System.currentTimeMillis();
View on GitHub (pinned to f3058517a1)