{"record":{"id":"1b1bb3ae4ced7fd3","repo":"pentaho/pentaho-kettle","slug":"error-comitting-connection","errorCode":null,"errorMessage":"Error comitting connection","messagePattern":"Error comitting connection","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":1122,"sourceCode":"      // The flag is in \"performRollback\", private only\n      //\n      if ( !Utils.isEmpty( connectionGroup ) && !force ) {\n        return;\n      }\n      if ( getDatabaseMetaData().supportsTransactions() ) {\n        if ( log.isDebug() ) {\n          log.logDebug( \"Commit on database connection [\" + toString() + \"]\" );\n        }\n        connection.commit();\n        nrExecutedCommits++;\n      } else {\n        if ( log.isDetailed() ) {\n          log.logDetailed( \"No commit possible on database connection [\" + toString() + \"]\" );\n        }\n      }\n    } catch ( Exception e ) {\n      if ( databaseMeta.supportsEmptyTransactions() ) {\n        throw new KettleDatabaseException( \"Error comitting connection\", e );\n      }\n    }\n  }\n\n  /**\n   * This methods may be removed in future.\n   *\n   * @param logTable\n   * @throws KettleDatabaseException\n   */\n  public void commitLog( LogTableCoreInterface logTable ) throws KettleDatabaseException {\n    this.commitLog( false, logTable );\n  }\n\n  /**\n   * This methods may be removed in future.\n   *\n   * @param force","sourceCodeStart":1104,"sourceCodeEnd":1140,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L1104-L1140","documentation":"KettleDatabaseException thrown by Database.commit() when connection.commit() throws an Exception AND databaseMeta.supportsEmptyTransactions() is true. Note the typo in the message ('comitting'). If the database does not support empty transactions, the exception is swallowed and only logged. Means the JDBC-level commit failed — the transaction was not persisted.","triggerScenarios":"Calling Database.commit() with an active connection where connection.commit() throws — constraint violation deferred to commit, deadlock victim, connection lost mid-transaction, or commit on a read-only connection.","commonSituations":"Deferred FK/unique constraint failures at commit time, network drop during transaction, deadlock/timeout on commit, committing on an autocommit-only or read-only connection.","solutions":["Inspect the wrapped cause for the DB-specific commit error (deadlock, constraint, connection lost)","Roll back the failed transaction and retry it","Verify the connection is still alive before commit; reconnect and re-execute the transaction if dropped","Check for constraint violations in the data written during the transaction"],"exampleFix":"// before\ndatabase.commit();\n// after\ntry {\n  database.commit();\n} catch ( KettleDatabaseException e ) {\n  database.rollback();\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if ( database.getConnection() == null || database.getConnection().isClosed() ) {\n  throw new IllegalStateException( \"Cannot commit: connection closed\" );\n}","typeGuard":"boolean canCommit( Database db ) throws SQLException {\n  Connection c = db.getConnection();\n  return c != null && !c.isClosed() && !c.getAutoCommit();\n}","tryCatchPattern":"try {\n  database.commit();\n} catch ( KettleDatabaseException e ) {\n  try { database.rollback(); } catch ( Exception ignore ) {}\n  throw new RuntimeException( \"Commit failed: \" + e.getCause().getMessage(), e );\n}","preventionTips":["Always pair commit with rollback in catch/finally","Watch for deadlocks and constraint violations in the wrapped cause","Keep transactions short to avoid connection loss mid-transaction","Verify the target DB supports the transaction semantics being used"],"tags":["jdbc","database","commit","transaction"],"backgroundTag":"database-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}