pentaho/pentaho-kettle · error · KettleDatabaseException
Error inserting/updating row
Error message
Error inserting/updating row
What it means
In the shared execute/insert path (execUpdate/insertRow with prepared statements), a non-batch SQLException during statement execution is wrapped as KettleDatabaseException('Error inserting/updating row'). This is the generic JDBC execution failure for a single-row insert/update: constraint violations, syntax errors, deadlocks, connection loss, etc. The cause contains the driver's real message.
Solutions
- Read the chained SQLException cause for the exact DB error (ORA-xxxx, MySQL error code)
- Fix the data causing constraint violations (deduplicate keys, handle nulls)
- Verify the target table exists and column types match the row metadata
- Check connection health / increase pool and network timeouts if connection loss
- Enable debug field (debug Db part label) to identify which insert/update part failed
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check for duplicate keys before insert // e.g. SELECT COUNT(*) FROM target WHERE key = ?
Try / catch
try {
database.insertRow(tableName, rowMeta, data);
} catch (KettleDatabaseException e) {
SQLException root = getRootSqlException(e);
if (root != null && isConstraintViolation(root)) {
// route row to error stream / alternate table
} else {
throw e;
}
} Prevention
- Use the step's error handling to divert rejected rows
- Keep string lengths within column sizes
- Deduplicate keys upstream (Sort + Unique rows)
- Verify target table exists in every environment
When it happens
Trigger: ps.executeUpdate()/execute() throwing SQLException with isBatchUpdate=false — e.g. duplicate key, NOT NULL violation, foreign key violation, table missing, connection broken, SQL syntax error.
Common situations: Duplicate primary keys from re-runs; truncation of strings longer than column size; table dropped/renamed; connection idle timeout killed the session; wrong schema/table name in the target table setting.
Related errors
- An error occurred executing SQL:
- Couldn't execute SQL:
- Couldn't find any rows because of an error :
- Couldn't get a result because of an error :
- Couldn't get field info from [" + sql + "]" + Const.CR
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/fadc1ee2c8390a6d.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:1620
ps.executeBatch();
commit();
ps.clearBatch();
} else {
debug = "insertRow normal commit";
commit();
}
written = 0;
rowsAreSafe = true;
}
return rowsAreSafe;
} catch ( BatchUpdateException ex ) {
throw createKettleDatabaseBatchException( "Error updating batch", ex );
} catch ( SQLException ex ) {
if ( isBatchUpdate ) {
throw createKettleDatabaseBatchException( "Error updating batch", ex );
} else {
throw new KettleDatabaseException( "Error inserting/updating row", ex );
}
} catch ( Exception e ) {
throw new KettleDatabaseException( "Unexpected error inserting/updating row in part [" + debug + "]", e );
}
}
/**
* Clears batch of insert prepared statement
*
* @throws KettleDatabaseException
* @deprecated
*/
@Deprecated
public void clearInsertBatch() throws KettleDatabaseException {
clearBatch( prepStatementInsert );
}
public void clearBatch( PreparedStatement preparedStatement ) throws KettleDatabaseException {View on GitHub (pinned to f3058517a1)