{"record":{"id":"98f4a9fc5faced2a","repo":"pentaho/pentaho-kettle","slug":"unable-to-prepare-combi-lookup-statement","errorCode":null,"errorMessage":"Unable to prepare combi-lookup statement","messagePattern":"Unable to prepare combi-lookup statement","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/combinationlookup/CombinationLookup.java","lineNumber":468,"sourceCode":"      }\n      // Add the ValueMeta for the null check, BUT cloning needed.\n      // Otherwise the field gets renamed and gives problems when referenced by previous steps.\n      data.lookupRowMeta.addValueMeta( inputRowMeta.getValueMeta( data.keynrs[ i ] ).clone() );\n\n      sql += \" ) )\";\n      sql += Const.CR;\n    }\n\n    try {\n      if ( log.isDebug() ) {\n        logDebug( \"preparing combi-lookup statement:\" + Const.CR + sql );\n      }\n      data.prepStatementLookup = data.db.getConnection().prepareStatement( databaseMeta.stripCR( sql ) );\n      if ( databaseMeta.supportsSetMaxRows() ) {\n        data.prepStatementLookup.setMaxRows( 1 ); // alywas get only 1 line back!\n      }\n    } catch ( SQLException ex ) {\n      throw new KettleDatabaseException( \"Unable to prepare combi-lookup statement\", ex );\n    }\n  }\n\n  /**\n   * This inserts new record into a junk dimension\n   */\n  public Long combiInsert( RowMetaInterface rowMeta, Object[] row, Long val_key, Long val_crc )\n    throws KettleDatabaseException {\n    String debug = \"Combination insert\";\n    DatabaseMeta databaseMeta = meta.getDatabaseMeta();\n    try {\n      if ( data.prepStatementInsert == null ) { // first time: construct prepared statement\n        debug = \"First: construct prepared statement\";\n\n        data.insertRowMeta = new RowMeta();\n\n        /*\n         * Construct the SQL statement...","sourceCodeStart":450,"sourceCodeEnd":486,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/combinationlookup/CombinationLookup.java#L450-L486","documentation":"setCombiLookup builds the SQL to look up an existing junk-dimension key and prepares a JDBC PreparedStatement. Any SQLException during prepare (or setMaxRows) is wrapped in a KettleDatabaseException 'Unable to prepare combi-lookup statement'.","triggerScenarios":"data.db.getConnection().prepareStatement(sql) throws — invalid SQL against the target database (bad table/column names in the junk dimension), wrong database type, or closed/broken connection.","commonSituations":"Junk dimension table deleted or renamed in the DB; wrong schema; database user lacking SELECT privilege; connection dropped before the first row; unsupported DB dialect producing invalid SQL.","solutions":["Check the nested SQLException for the real database message","Verify the dimension table, schema and columns exist and are SELECT-able by the DB user","Test the database connection in the transformation's DB metadata (Test button)","Confirm the database dialect matches the actual server"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Verify the junk dimension table exists before running\nDatabase db = new Database(parent, databaseMeta);\ndb.connect();\nif (!db.checkTableExists(schemaTable)) {\n  throw new IllegalStateException(\"Junk dimension table missing: \" + schemaTable);\n}\ndb.disconnect();","typeGuard":null,"tryCatchPattern":"try {\n  trans.execute(null);\n  trans.waitUntilFinished();\n} catch (KettleDatabaseException e) {\n  Throwable root = e; while (root.getCause() != null) root = root.getCause();\n  log.error(\"Combi-lookup prepare failed: \" + root.getMessage(), root);\n  if (root instanceof java.sql.SQLRecoverableException) { /* reconnect and retry */ }\n}","preventionTips":["Test the DB connection metadata before executing","Confirm table/column names and SELECT grants","Enable connection pooling with validation queries"],"tags":["kettle","pdi","jdbc","sql","database"],"backgroundTag":"sql-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"}