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

  1. Read the chained SQLException cause for the exact DB error (ORA-xxxx, MySQL error code)
  2. Fix the data causing constraint violations (deduplicate keys, handle nulls)
  3. Verify the target table exists and column types match the row metadata
  4. Check connection health / increase pool and network timeouts if connection loss
  5. 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

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


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)