pentaho/pentaho-kettle · error · KettleDatabaseException

Error setting value # [] on prepared statement

Error message

Error setting value # [] on prepared statement

What it means

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.

Solutions

  1. Inspect the chained SQLException for the JDBC binding failure reason
  2. Ensure the value's type matches the prepared statement parameter's SQL type
  3. Clean null/empty handling so setNull is called with the correct SQL type
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:5495 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/6a866eac653d2938. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/row/value/ValueMetaBase.java:5495

            preparedStatement.setBigDecimal( index, getBigNumber( data ) );
          } else {
            preparedStatement.setNull( index, java.sql.Types.DECIMAL );
          }
          break;
        case ValueMetaInterface.TYPE_BINARY:
          if ( !isNull( data ) ) {
            preparedStatement.setBytes( index, getBinary( data ) );
          } else {
            preparedStatement.setNull( index, java.sql.Types.BINARY );
          }
          break;
        default:
          // placeholder
          preparedStatement.setNull( index, java.sql.Types.VARCHAR );
          break;
      }
    } catch ( Exception e ) {
      throw new KettleDatabaseException( "Error setting value #" + index + " [" + toStringMeta()
          + "] on prepared statement", e );
    }
  }

  @Override
  public Object getNativeDataType( Object object ) throws KettleValueException {
    switch ( getStorageType() ) {
      case STORAGE_TYPE_BINARY_STRING:
        return convertBinaryStringToNativeType( (byte[]) object );
      case STORAGE_TYPE_INDEXED:
        return index[(Integer) object];
      case STORAGE_TYPE_NORMAL:
      default:
        return object;
    }
  }

  @Override

View on GitHub (pinned to f3058517a1)