{"record":{"id":"6a866eac653d2938","repo":"pentaho/pentaho-kettle","slug":"error-setting-value-on-prepared-statement","errorCode":null,"errorMessage":"Error setting value # [] on prepared statement","messagePattern":"Error setting value # \\[\\] on prepared statement","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java","lineNumber":5495,"sourceCode":"            preparedStatement.setBigDecimal( index, getBigNumber( data ) );\n          } else {\n            preparedStatement.setNull( index, java.sql.Types.DECIMAL );\n          }\n          break;\n        case ValueMetaInterface.TYPE_BINARY:\n          if ( !isNull( data ) ) {\n            preparedStatement.setBytes( index, getBinary( data ) );\n          } else {\n            preparedStatement.setNull( index, java.sql.Types.BINARY );\n          }\n          break;\n        default:\n          // placeholder\n          preparedStatement.setNull( index, java.sql.Types.VARCHAR );\n          break;\n      }\n    } catch ( Exception e ) {\n      throw new KettleDatabaseException( \"Error setting value #\" + index + \" [\" + toStringMeta()\n          + \"] on prepared statement\", e );\n    }\n  }\n\n  @Override\n  public Object getNativeDataType( Object object ) throws KettleValueException {\n    switch ( getStorageType() ) {\n      case STORAGE_TYPE_BINARY_STRING:\n        return convertBinaryStringToNativeType( (byte[]) object );\n      case STORAGE_TYPE_INDEXED:\n        return index[(Integer) object];\n      case STORAGE_TYPE_NORMAL:\n      default:\n        return object;\n    }\n  }\n\n  @Override","sourceCodeStart":5477,"sourceCodeEnd":5513,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java#L5477-L5513","documentation":"Wrapper error from ValueMetaBase.setValuePreparedStatement(): binding the value at the given index via setBigDecimal/setBytes/setNull (or the default VARCHAR-null placeholder for an unrecognized type) threw a SQLException. The value's name and its data array are referenced in the message; the cause is chained.","triggerScenarios":"Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:5495 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the chained SQLException for the JDBC binding failure reason","Ensure the value's type matches the prepared statement parameter's SQL type","Clean null/empty handling so setNull is called with the correct SQL type"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}