{"record":{"id":"36fa2833089973cb","repo":"pentaho/pentaho-kettle","slug":"offending-row","errorCode":null,"errorMessage":"offending row : ","messagePattern":"offending row : ","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":1395,"sourceCode":"\n    v.setPreparedStatementValue( databaseMeta, ps, pos, object );\n  }\n\n  public void setValues( RowMetaAndData row, PreparedStatement ps ) throws KettleDatabaseException {\n    setValues( row.getRowMeta(), row.getData(), ps );\n  }\n\n  public void setValues( RowMetaInterface rowMeta, Object[] data, PreparedStatement ps )\n    throws KettleDatabaseException {\n    // now set the values in the row!\n    for ( int i = 0; i < rowMeta.size(); i++ ) {\n      ValueMetaInterface v = rowMeta.getValueMeta( i );\n      Object object = data[ i ];\n\n      try {\n        setValue( ps, v, object, i + 1 );\n      } catch ( KettleDatabaseException e ) {\n        throw new KettleDatabaseException( \"offending row : \" + rowMeta, e );\n      }\n    }\n  }\n\n  /**\n   * Sets the values of the preparedStatement pstmt.\n   *\n   * @param rowMeta\n   * @param data\n   */\n  public void setValues( RowMetaInterface rowMeta, Object[] data, PreparedStatement ps, int ignoreThisValueIndex )\n    throws KettleDatabaseException {\n    // now set the values in the row!\n    int index = 0;\n    for ( int i = 0; i < rowMeta.size(); i++ ) {\n      if ( i != ignoreThisValueIndex ) {\n        ValueMetaInterface v = rowMeta.getValueMeta( i );\n        Object object = data[ i ];","sourceCodeStart":1377,"sourceCodeEnd":1413,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L1377-L1413","documentation":"setValues(PreparedStatement, RowMetaInterface, Object[]) sets each field value on a JDBC PreparedStatement via setValue(); if any field fails to bind, the error is rethrown as KettleDatabaseException('offending row : ' + rowMeta) with the original binding exception as cause. The rowMeta toString in the message identifies the row layout (field names/types) that failed.","triggerScenarios":"Calling Database.setValues / insertRow / execStatement value-binding paths where setValue(ps, v, object, i+1) throws KettleDatabaseException — e.g. data object type incompatible with the declared ValueMeta type, nulls in non-nullable contexts, or unsupported value format for the driver.","commonSituations":"A transformation stream column changed type (String vs Number) upstream; a field contains data too large for the column; passing Kettle values with the wrong storage type after a metadata edit; driver rejects a date/number format.","solutions":["Read the cause (KettleDatabaseException / SQLException) to see which bind parameter index failed and why","Verify row metadata matches actual data types with rowMeta.toString() in the message; fix upstream Select Values / type conversion steps","Convert problematic values explicitly before insert (e.g. use ValueDataUtil or explicit setValue with correct type)","Check column lengths and nullability against the data being inserted","Test the same insert manually via SQL to isolate driver vs data issues"],"exampleFix":"// before\ndatabase.insertRow(table, rowMeta, rowData);\n// after\ntry {\n  database.insertRow(table, rowMeta, rowData);\n} catch (KettleDatabaseException e) {\n  throw new KettleDatabaseException(\"Failed row: \" + rowMeta.getString(data, \"id\"), e);\n}","handlingStrategy":"validation","validationCode":"for (int i = 0; i < rowMeta.size(); i++) {\n  ValueMetaInterface v = rowMeta.getValueMeta(i);\n  if (data[i] != null && !v.getNativeDataTypeClass().isInstance(data[i])) {\n    throw new IllegalStateException(\"Field \" + v.getName() + \" expects \" + v.getTypeDesc());\n  }\n}","typeGuard":"boolean matchesMeta(ValueMetaInterface v, Object o) {\n  return o == null || v.getNativeDataTypeClass().isAssignableFrom(o.getClass());\n}","tryCatchPattern":"try {\n  database.setValues(rowMeta, data, ps);\n} catch (KettleDatabaseException e) {\n  throw new KettleDatabaseException(\"Bad row id=\" + data[0] + \": \" + e.getMessage(), e);\n}","preventionTips":["Fix column types explicitly with a Select Values step before writing","Keep row metadata and target table DDL in sync","Trim/limit string lengths to column sizes","Test inserts against the real DB schema in CI"],"tags":["jdbc","data-binding","type-mismatch"],"backgroundTag":"database-write-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"}