pentaho/pentaho-kettle · error · KettleDatabaseException

Unable to get table types from database!

Error message

Unable to get table types from database!

What it means

Database.getTableTypes() reads the JDBC DatabaseMetaData table-type list (via getTableTypes/getTables); any SQLException while reading is wrapped in this KettleDatabaseException. It means the database's table-type metadata could not be retrieved.

Solutions

  1. Ensure the connection is open (db.connect()) before calling getTableTypes
  2. Inspect the chained SQLException for driver-level metadata support issues
  3. Test with a standard JDBC driver for your database version
  4. Catch KettleDatabaseException and fall back to known defaults (e.g. "TABLE","VIEW") when metadata is unavailable

Example fix

// before
db.disconnect();
String[] types = db.getTableTypes(); // fails
// after
db.connect();
String[] types = db.getTableTypes();
Defensive patterns

Strategy: try-catch

Validate before calling

if (db.getConnection() == null || db.getConnection().isClosed()) {
  db.connect(); // or throw
}

Type guard

boolean metadataReady(Database db) { try { return db.getConnection() != null && !db.getConnection().isClosed(); } catch (SQLException e) { return false; } }

Try / catch

String[] types;
try {
  types = db.getTableTypes();
} catch (KettleDatabaseException e) {
  log.warn("Could not read table types, using defaults", e);
  types = new String[] { "TABLE", "VIEW" }; // safe fallback
}

Prevention

When it happens

Trigger: Calling getTableTypes()/getTablenames() on a connection whose metadata query fails — closed connection, driver not supporting the metadata call, or metadata access denied.

Common situations: Calling after db.disconnect(), drivers with incomplete DatabaseMetaData implementations (some embedded/NoSQL bridges), restricted catalog access, or DB session killed between connect and metadata call.

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

Appendix: source

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

  }

  public RowMetaInterface getReturnRowMeta() {
    return rowMeta;
  }

  public String[] getTableTypes() throws KettleDatabaseException {
    try {
      ArrayList<String> types = new ArrayList<>();

      ResultSet rstt = getDatabaseMetaData().getTableTypes();
      while ( rstt.next() ) {
        String ttype = rstt.getString( "TABLE_TYPE" );
        types.add( ttype );
      }

      return types.toArray( new String[ types.size() ] );
    } catch ( SQLException e ) {
      throw new KettleDatabaseException( "Unable to get table types from database!", e );
    }
  }

  public String[] getTablenames() throws KettleDatabaseException {
    return getTablenames( false );
  }

  public String[] getTablenames( boolean includeSchema ) throws KettleDatabaseException {
    return getTablenames( null, includeSchema );
  }

  public String[] getTablenames( String schemanamein, boolean includeSchema ) throws KettleDatabaseException {
    return getTablenames( schemanamein, includeSchema, null );
  }

  public String[] getTablenames( String schemanamein, boolean includeSchema, Map<String, String> props )
    throws KettleDatabaseException {
    Map<String, Collection<String>> tableMap = getTableMap( schemanamein, props );

View on GitHub (pinned to f3058517a1)