{"record":{"id":"6f407d00a190f631","repo":"pentaho/pentaho-kettle","slug":"tableoutputmeta-exception-connectionnotdefined","errorCode":"TableOutputMeta.Exception.ConnectionNotDefined","errorMessage":"TableOutputMeta.Exception.ConnectionNotDefined","messagePattern":"TableOutputMeta\\.Exception\\.ConnectionNotDefined","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutputMeta.java","lineNumber":929,"sourceCode":"\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, \"TableOutputMeta.Exception.TableNotFound\" ) );\n          }\n        } else {\n          throw new KettleException( BaseMessages.getString( PKG, \"TableOutputMeta.Exception.TableNotSpecified\" ) );\n        }\n      } catch ( Exception e ) {\n        throw new KettleException(\n          BaseMessages.getString( PKG, \"TableOutputMeta.Exception.ErrorGettingFields\" ), e );\n      } finally {\n        db.close();\n      }\n    } else {\n      throw new KettleException( BaseMessages.getString( PKG, \"TableOutputMeta.Exception.ConnectionNotDefined\" ) );\n    }\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  /**\n   * @return Fields containing the values in the input stream to insert.\n   */\n  public String[] getFieldStream() {\n    return fieldStream;\n  }","sourceCodeStart":911,"sourceCodeEnd":947,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutputMeta.java#L911-L947","documentation":"Thrown when the Table Output step has no database connection defined (databaseMeta is null) but the code needs one to look up table field metadata. The step cannot determine the target table's layout without a connection, so it raises this keyed KettleException before attempting any database work.","triggerScenarios":"Executing the getTableFields()/getFields path when databaseMeta was never set — the Database connection field in the step dialog is empty, or the connection variable resolves to nothing.","commonSituations":"Newly added Table Output step where the connection was never chosen; transformation copied between environments where the shared connection is missing and the reference is dropped; programmatic metadata construction (API/SDK usage) that skips setDatabaseMeta.","solutions":["Select a database connection in the Table Output dialog's 'Database connection' dropdown.","If the dropdown is empty, create the connection in the transformation's database connections view first.","For API usage, call setDatabaseMeta(DatabaseMeta) on the TableOutputMeta before getFields/getTableFields.","Verify the transformation loaded correctly so the shared connection reference resolved (not null)."],"exampleFix":"// before (API usage, no connection)\nTableOutputMeta meta = new TableOutputMeta();\nmeta.setTableName(\"customers\");\n// after\nTableOutputMeta meta = new TableOutputMeta();\nmeta.setDatabaseMeta(DatabaseMeta.findDatabase(transMeta.getDatabases(), \"PostgresDW\"));\nmeta.setTableName(\"customers\");","handlingStrategy":"validation","validationCode":"// guard before running\nif (meta.getDatabaseMeta() == null) {\n  throw new IllegalArgumentException(\"Table Output step has no database connection defined\");\n}","typeGuard":null,"tryCatchPattern":"try { fields = meta.getTableFields(); }\ncatch (KettleException e) {\n  if (e.getMessage().contains(\"ConnectionNotDefined\")) { /* assign a connection */ }\n  else throw e;\n}","preventionTips":["Never save a Table Output step without a selected connection","Check connection references after copying transformations between environments","In API code, always call setDatabaseMeta before getFields"],"tags":["kettle","table-output","configuration","connection"],"backgroundTag":"missing-required-config-field","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"}