{"record":{"id":"92f19801f183dfc1","repo":"pentaho/pentaho-kettle","slug":"sqlfileoutputmeta-exception-errorgettingfields","errorCode":"SQLFileOutputMeta.Exception.ErrorGettingFields","errorMessage":"SQLFileOutputMeta.Exception.ErrorGettingFields","messagePattern":"SQLFileOutputMeta\\.Exception\\.ErrorGettingFields","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/sqlfileoutput/SQLFileOutputMeta.java","lineNumber":811,"sourceCode":"    String realSchemaName = space.environmentSubstitute( schemaName );\n\n    if ( databaseMeta != null ) {\n      Database db = new Database( loggingObject, databaseMeta );\n      try {\n        db.connect();\n\n        if ( !Utils.isEmpty( realTableName ) ) {\n          // Check if this table exists...\n          if ( db.checkTableExists( realSchemaName, realTableName ) ) {\n            return db.getTableFieldsMeta( realSchemaName, realTableName );\n          } else {\n            throw new KettleException( BaseMessages.getString( PKG, \"SQLFileOutputMeta.Exception.TableNotFound\" ) );\n          }\n        } else {\n          throw new KettleException( BaseMessages.getString( PKG, \"SQLFileOutputMeta.Exception.TableNotSpecified\" ) );\n        }\n      } catch ( Exception e ) {\n        throw new KettleException(\n          BaseMessages.getString( PKG, \"SQLFileOutputMeta.Exception.ErrorGettingFields\" ), e );\n      } finally {\n        db.close();\n      }\n    } else {\n      throw new KettleException( BaseMessages.getString( PKG, \"SQLFileOutputMeta.Exception.ConnectionNotDefined\" ) );\n    }\n  }\n\n  public DatabaseMeta[] getUsedDatabaseConnections() {\n    if ( databaseMeta != null ) {\n      return new DatabaseMeta[] { databaseMeta };\n    } else {\n      return super.getUsedDatabaseConnections();\n    }\n  }\n\n  /**","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/sqlfileoutput/SQLFileOutputMeta.java#L793-L829","documentation":"The table-fields lookup in SQLFileOutputMeta wraps its whole body in try/catch: any exception during connect, checkTableExists or getTableFieldsMeta is rethrown as KettleException 'SQLFileOutputMeta.Exception.ErrorGettingFields' with the original exception chained. It is a generic wrapper meaning 'could not read the target table's field metadata', with the root cause in the cause chain.","triggerScenarios":"Any failure inside the lookup: JDBC connection failure (wrong host/port/credentials), driver class not on the classpath, SQL error while querying table metadata (checkTableExists/getTableFieldsMeta), network timeouts, or one of the TableNotFound/TableNotSpecified exceptions being wrapped.","commonSituations":"Database firewall blocking the designer host; missing JDBC driver jar in lib/; wrong password after rotation; DB briefly down; Oracle ORA- errors surfacing through the wrapper; VPN not connected when opening Spoon.","solutions":["Inspect the chained cause exception for the real JDBC/SQL error and fix that root problem","Test the database connection from the step dialog / connection explorer (Test button)","Ensure the correct JDBC driver jar is installed in PDI's lib folder","Confirm network/VPN connectivity and credentials, then retry Get Fields"],"exampleFix":"// before: MySQL driver missing -> ClassNotFoundException wrapped as ErrorGettingFields\n// lib/ contains only postgresql-42.x.jar\n// after: add the driver\ncp mysql-connector-j-8.x.jar /data-integration/lib/\n// then restart Spoon and re-run Get Fields","handlingStrategy":"try-catch","validationCode":"// Pre-check connection before field lookup:\nDatabase db = new Database( parent, meta.getDatabaseMeta() );\ntry {\n  db.connect();\n} catch ( KettleDatabaseException e ) {\n  throw new IllegalStateException( \"Connection test failed: \" + e.getMessage() );\n} finally { db.disconnect(); }","typeGuard":null,"tryCatchPattern":"try {\n  RowMetaInterface fields = meta.getTableFields();\n} catch ( KettleException e ) {\n  log.error( \"ErrorGettingFields root cause: {}\", e.getCause() ); // inspect the JDBC cause\n}","preventionTips":["Use the connection Test button before Get Fields","Install the required JDBC driver in data-integration/lib","Check VPN/firewall reachability of the DB host from the designer machine","Always read getCause() — this message is only a wrapper"],"tags":["kettle","pentaho","sql","jdbc","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"}