{"record":{"id":"a9bc0a09c582d413","repo":"pentaho/pentaho-kettle","slug":"database-exception-unabletoenableautocommit-i18n-unable-to","errorCode":null,"errorMessage":"Database.Exception.UnableToEnableAutoCommit (i18n: Unable to enable auto-commit on database connection {0})","messagePattern":"Database\\.Exception\\.UnableToEnableAutoCommit \\(i18n: Unable to enable auto-commit on database connection (.+?)\\)","errorType":"exception","errorClass":"KettleDatabaseException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/database/Database.java","lineNumber":1081,"sourceCode":"        log.logDetailed( \"Auto commit \" + onOff );\n      }\n    } catch ( Exception e ) {\n      if ( log.isDebug() ) {\n        log.logDebug( \"Can't turn auto commit \" + onOff + Const.CR + Const.getStackTracker( e ) );\n      }\n    }\n  }\n\n  public void setCommitSize( int size ) {\n    commitsize = size;\n  }\n\n  public void setAutoCommit( boolean useAutoCommit ) throws KettleDatabaseException {\n    try {\n      connection.setAutoCommit( useAutoCommit );\n    } catch ( SQLException e ) {\n      if ( useAutoCommit ) {\n        throw new KettleDatabaseException( BaseMessages.getString(\n          PKG, \"Database.Exception.UnableToEnableAutoCommit\", toString() ) );\n      } else {\n        throw new KettleDatabaseException( BaseMessages.getString(\n          PKG, \"Database.Exception.UnableToDisableAutoCommit\", toString() ) );\n      }\n    }\n  }\n\n  /**\n   * Perform a commit the connection if this is supported by the database\n   */\n  public void commit() throws KettleDatabaseException {\n    commit( false );\n  }\n\n  public void commit( boolean force ) throws KettleDatabaseException {\n    try {\n      // Don't do the commit, wait until the end of the transformation.","sourceCodeStart":1063,"sourceCodeEnd":1099,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/database/Database.java#L1063-L1099","documentation":"i18n-keyed KettleDatabaseException (Database.Exception.UnableToEnableAutoCommit) thrown by Database.setAutoCommit(true) when Connection.setAutoCommit(true) throws a SQLException. It means the driver could not switch the connection into auto-commit mode, typically because the connection is broken or the transaction state is odd.","triggerScenarios":"Calling Database.setAutoCommit(true) (directly or via commit paths) when connection.setAutoCommit(true) throws SQLException — dead/broken connection, active transaction the driver refuses to end, or driver limitation.","commonSituations":"Connection dropped by DB mid-transaction, driver that disallows toggling autocommit while a transaction/result set is open, XA or pooled connections with restricted autocommit control.","solutions":["Verify the connection is still open; reconnect if it was dropped","Commit or roll back and close open statements/result sets before toggling autocommit","Check driver/pool constraints (some pools forbid changing autocommit per-connection)","Retry setAutoCommit after reconnecting"],"exampleFix":"// before\ndatabase.setAutoCommit(true);\n// after\nif ( database.getConnection() != null && !database.getConnection().isClosed() ) {\n  database.setAutoCommit( true );\n} else {\n  database.connect();\n  database.setAutoCommit( true );\n}","handlingStrategy":"try-catch","validationCode":"Connection c = database.getConnection();\nif ( c == null || c.isClosed() ) {\n  database.connect();\n}","typeGuard":"boolean canToggleAutoCommit( Database db ) throws SQLException {\n  Connection c = db.getConnection();\n  return c != null && !c.isClosed();\n}","tryCatchPattern":"try {\n  database.setAutoCommit( true );\n} catch ( KettleDatabaseException e ) {\n  database.disconnect();\n  database.connect();\n  database.setAutoCommit( true );\n}","preventionTips":["Close statements/result sets before switching autocommit","Check pool settings that may forbid autocommit changes","Validate connection liveness before transaction-mode changes"],"tags":["jdbc","database","autocommit","transaction"],"backgroundTag":"invalid-state-transition","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"}