pentaho/pentaho-kettle · error · KettleDatabaseException
Unexpected error inserting row
Error message
Unexpected error inserting row
What it means
The generic catch-all in the batch flush path: any non-SQLException exception thrown during executeBatch()/commit()/clearBatch() is wrapped in a KettleDatabaseException with this message. It signals an unexpected (usually runtime) failure rather than a plain JDBC SQL error.
Solutions
- Read the cause chain of the KettleDatabaseException to find the underlying runtime error.
- Update the JDBC driver to a version compatible with the database and Pentaho/Kettle version.
- Reduce commit/batch size to lower memory pressure.
- If the connection was closed, check for concurrent use of the same database connection across steps.
Example fix
// before: commit size 100000 causing OOM with huge rows // after: set 'Commit size' to 1000 in the TableOutput dialog
Defensive patterns
Strategy: try-catch
Try / catch
try {
insertStatement.executeBatch();
} catch ( KettleDatabaseException e ) {
Throwable cause = e.getCause();
log.error( "Unexpected batch failure", cause ); // inspect cause for driver/runtime issue
data.db.rollback();
} Prevention
- Keep the JDBC driver version aligned with both the DB server and the Pentaho version
- Avoid oversized commit sizes that can exhaust memory
- Never share one database connection across concurrent steps/threads
When it happens
Trigger: A RuntimeException or driver-specific non-SQLException is thrown from insertStatement.executeBatch(), data.db.commit(), or clearBatch() while batch inserting in writeToTable.
Common situations: JDBC driver bugs or driver class version mismatches; connection closed by another thread; OutOfMemoryError handling large batches; misconfigured Kettle database connection object.
Related errors
- Error updating batch
- Errors encountered (first 10): ...
- No generated keys while "return generated keys" is active!
- dbInterface.getUnsupportedTableOutputMessage()
- Error evaluating Internet address value metadata
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/36209cf3f011c9a5.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java:295
if ( data.useSafePoints ) {
if ( data.releaseSavepoint ) {
data.db.releaseSavepoint( data.savepoint );
}
}
// Perform a commit if needed
//
if ( ( data.commitSize > 0 ) && ( ( commitCounter % data.commitSize ) == 0 ) ) {
if ( data.db.getUseBatchInsert( data.batchMode ) ) {
try {
insertStatement.executeBatch();
data.db.commit();
insertStatement.clearBatch();
} catch ( SQLException ex ) {
throw Database.createKettleDatabaseBatchException( "Error updating batch", ex );
} catch ( Exception ex ) {
throw new KettleDatabaseException( "Unexpected error inserting row", ex );
}
} else {
// insertRow normal commit
data.db.commit();
}
// Clear the batch/commit counter...
//
data.commitCounterMap.put( tableName, Integer.valueOf( 0 ) );
rowIsSafe = true;
} else {
rowIsSafe = false;
}
// See if we need to get back the keys as well...
if ( meta.isReturningGeneratedKeys() ) {
RowMetaAndData extraKeys = data.db.getGeneratedKeys( insertStatement );
if ( extraKeys.getRowMeta().size() > 0 ) {View on GitHub (pinned to f3058517a1)