{"record":{"id":"126b9d38472708cc","repo":"pentaho/pentaho-kettle","slug":"unable-to-get-table-names-from-the-database-meta-data","errorCode":null,"errorMessage":"Unable to get table-names from the database meta-data.","messagePattern":"Unable to get table-names from the database meta-data\\.","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":2257,"sourceCode":"\n  /**\n   * Retrieves the table description matching the schema and table name.\n   *\n   * @param schema the schema name pattern\n   * @param table  the table name pattern\n   * @return table description row set\n   * @throws KettleDatabaseException if DatabaseMetaData is null or some database error occurs\n   */\n  private ResultSet getTableMetaData( String schema, String table ) throws KettleDatabaseException {\n    ResultSet tables = null;\n    if ( getDatabaseMetaData() == null ) {\n      throw new KettleDatabaseException( BaseMessages.getString( PKG, \"Database.Error.UnableToGetDbMeta\" ) );\n    }\n    try {\n      tables = databaseMeta.getTables(\n        getDatabaseMetaData(), schema, table, TABLE_TYPES_TO_GET );\n    } catch ( SQLException e ) {\n      throw new KettleDatabaseException( BaseMessages.getString( PKG, \"Database.Error.UnableToGetTableNames\" ), e );\n    }\n    if ( tables == null ) {\n      throw new KettleDatabaseException( BaseMessages.getString( PKG, \"Database.Error.UnableToGetTableNames\" ) );\n    }\n    return tables;\n  }\n\n  /**\n   * Retrieves the columns metadata matching the schema and table name.\n   *\n   * @param schema the schema name pattern\n   * @param table  the table name pattern\n   * @return columns description row set\n   * @throws KettleDatabaseException if DatabaseMetaData is null or some database error occurs\n   */\n  private ResultSet getColumnsMetaData( String schema, String table ) throws KettleDatabaseException {\n    ResultSet columns = null;\n    if ( getDatabaseMetaData() == null ) {","sourceCodeStart":2239,"sourceCodeEnd":2275,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L2239-L2275","documentation":"Also thrown by Database.getTableMetaData(schema, table): either the databaseMeta.getTables(...) JDBC call throws SQLException, or it returns null. Both mean the driver could not produce the list of matching table descriptions for the given schema/table and TABLE_TYPES_TO_GET.","triggerScenarios":"getTableMetaData (used by getTableFields etc.) when DatabaseMetaData.getTables() throws SQLException (connectivity/permissions) or returns null (driver quirk, wrong catalog/schema/table-type filter).","commonSituations":"Drivers (e.g. some older ones) returning null from getTables for unusual catalogs; user without privileges to read system catalog views; schema/table name casing not matching the database's stored case.","solutions":["Check the SQLException cause for connectivity or permission errors","Match schema/table name casing exactly as stored in the database (often uppercase)","Ensure the user can query the metadata catalog for the schema","Upgrade the JDBC driver if getTables() returns null despite valid arguments"],"exampleFix":"// before\nRowMetaInterface fields = db.getTableFields(\"mytable\"); // schema not set\n// after\nRowMetaInterface fields = db.getTableFields(\"PUBLIC.MYTABLE\");","handlingStrategy":"try-catch","validationCode":"if (table == null || table.trim().isEmpty()) throw new IllegalArgumentException(\"Table name required\");","typeGuard":null,"tryCatchPattern":"try {\n  RowMetaInterface fields = database.getTableFields(schema, table);\n} catch (KettleDatabaseException e) {\n  Throwable cause = e.getCause();\n  logError(\"getTables failed for \" + schema + \".\" + table + \": \" + (cause != null ? cause.getMessage() : \"null result\"), e);\n  throw e;\n}","preventionTips":["Use exact stored casing for schema/table names","Grant access to metadata catalog views","Upgrade JDBC drivers where getTables() returns null","Verify table type filters (TABLE, VIEW) match the target object"],"tags":["database","metadata","jdbc"],"backgroundTag":"database-query-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}