{"record":{"id":"7c5fc8a753590e08","repo":"pentaho/pentaho-kettle","slug":"failed-to-fetch-fields-from-jdbc-meta","errorCode":null,"errorMessage":"Failed to fetch fields from jdbc meta ","messagePattern":"Failed to fetch fields from jdbc meta ","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":2648,"sourceCode":"            }\n          } catch ( KettleDatabaseException e ) {\n            // That's ok. The VMI impl doesn't like this data type.\n            if ( log.isDebug() ) {\n              log.logDebug( \"Skipping ValueMetaInterface:\" + valueMetaClass.getClass().getName(), e );\n            }\n          }\n        }\n        fields.addValueMeta( valueMeta );\n      }\n\n      // Store in cache!!\n      if ( dbcache != null && entry != null && fields != null ) {\n        dbcache.put( entry, fields );\n      }\n\n      return fields;\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( \"Failed to fetch fields from jdbc meta \", e );\n    }\n\n  }\n\n  public RowMetaInterface getQueryFields( String sql, boolean param, RowMetaInterface inform, Object[] data )\n    throws KettleDatabaseException {\n    RowMetaInterface fields;\n    DBCache dbcache = DBCache.getInstance();\n\n    DBCacheEntry entry = null;\n\n    // Check the cache first!\n    //\n    if ( dbcache != null ) {\n      entry = new DBCacheEntry( databaseMeta.getName(), sql );\n      fields = dbcache.get( entry );\n      if ( fields != null ) {\n        return fields;","sourceCodeStart":2630,"sourceCodeEnd":2666,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L2630-L2666","documentation":"Thrown by the table-fields retrieval path (with DB cache) when the JDBC metadata field fetch fails with any Exception. Kettle wraps it into this KettleDatabaseException before returning, including the original cause.","triggerScenarios":"Any Exception in getTableFields while reading ResultSetMetaData/DatabaseMetaData for the table's fields, e.g. getColumnsMetaData throwing, cache interactions aside.","commonSituations":"Non-existent tables, missing metadata privileges, broken connections, or drivers with incomplete metadata support.","solutions":["Confirm the table exists and the user has metadata access","Inspect the wrapped cause exception for the driver-level error","Reconnect and retry; stale connections are a frequent cause","Clear the DBCache if a stale cached entry points to a dropped table"],"exampleFix":"// before\nRowMetaInterface rm = db.getTableFields(\"old_table\"); // table dropped\n// after\nif (db.tableExists(\"new_table\")) {\n  RowMetaInterface rm = db.getTableFields(\"new_table\");\n}","handlingStrategy":"try-catch","validationCode":"if (!db.checkConnectionOpen()) db.connect();\nif (!db.tableExists(schema, table)) {\n  throw new IllegalStateException(\"table missing: \" + table);\n}","typeGuard":null,"tryCatchPattern":"try {\n  RowMetaInterface rm = db.getTableFields(schema, table);\n} catch (KettleDatabaseException e) {\n  Throwable cause = e.getCause();\n  log.error(\"field fetch failed: \" + cause, cause);\n}","preventionTips":["Verify table existence and privileges first","Reconnect stale sessions before metadata work","Clear DBCache entries after DDL changes"],"tags":["jdbc","table-fields","metadata"],"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"}