pentaho/pentaho-kettle · error · KettleDatabaseException

Unexpected error inserting row

Error message

Unexpected error inserting row

What it means

Thrown in lookupValues() in batch mode when the batch flush block throws a non-SQLException (any other Exception). It wraps the original exception in a KettleDatabaseException with the generic message 'Unexpected error inserting row', meaning the failure was not a plain JDBC SQLException (e.g. runtime error while building/flushing the batch).

Solutions

  1. Inspect the wrapped cause (getCause) of the KettleDatabaseException to identify the actual unexpected exception.
  2. Verify the correct JDBC driver version is installed for the target database.
  3. Toggle off batch mode to isolate whether the failure is batch-specific.
  4. Check heap/memory availability if batches are very large; reduce batch/commit size.
Defensive patterns

Strategy: try-catch

Try / catch

catch (KettleDatabaseException e) {
  if ("Unexpected error inserting row".equals(e.getMessage())) {
    Throwable cause = e.getCause();
    logError("Non-SQL failure during batch: " + cause);
  }
  throw e;
}

Prevention

When it happens

Trigger: data.batchMode is true and code in the try block around executeBatch()/commit() throws an Exception that is not a SQLException — e.g. NPE from an uninitialized statement, driver-specific unchecked exceptions.

Common situations: JDBC driver bugs or driver class mismatches; statements not initialized because an earlier branch skipped preparing them; OOM or driver-level runtime errors during large batches.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/synchronizeaftermerge/SynchronizeAfterMerge.java:380

            try {
              if ( performInsert ) {
                data.insertStatement.executeBatch();
                data.db.commit();
                data.insertStatement.clearBatch();
              } else if ( performUpdate ) {
                data.updateStatement.executeBatch();
                data.db.commit();
                data.updateStatement.clearBatch();
              } else if ( performDelete ) {
                data.deleteStatement.executeBatch();
                data.db.commit();
                data.deleteStatement.clearBatch();
              }
            } catch ( SQLException ex ) {
              throw Database.createKettleDatabaseBatchException( BaseMessages.getString( PKG,
                "SynchronizeAfterMerge.Error.UpdatingBatch" ), 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;
        }
      }
    } catch ( KettleDatabaseBatchException be ) {
      errorMessage = be.toString();
      batchProblem = true;
      sendToErrorRow = true;
      updateCounts = be.getUpdateCounts();

View on GitHub (pinned to f3058517a1)