pentaho/pentaho-kettle · error · KettleDatabaseException

Database.Exception.UnableToEnableAutoCommit

Error message

Database.Exception.UnableToEnableAutoCommit (i18n: Unable to enable auto-commit on database connection {0})

What it means

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.

Solutions

  1. Verify the connection is still open; reconnect if it was dropped
  2. Commit or roll back and close open statements/result sets before toggling autocommit
  3. Check driver/pool constraints (some pools forbid changing autocommit per-connection)
  4. Retry setAutoCommit after reconnecting

Example fix

// before
database.setAutoCommit(true);
// after
if ( database.getConnection() != null && !database.getConnection().isClosed() ) {
  database.setAutoCommit( true );
} else {
  database.connect();
  database.setAutoCommit( true );
}
Defensive patterns

Strategy: try-catch

Validate before calling

Connection c = database.getConnection();
if ( c == null || c.isClosed() ) {
  database.connect();
}

Type guard

boolean canToggleAutoCommit( Database db ) throws SQLException {
  Connection c = db.getConnection();
  return c != null && !c.isClosed();
}

Try / catch

try {
  database.setAutoCommit( true );
} catch ( KettleDatabaseException e ) {
  database.disconnect();
  database.connect();
  database.setAutoCommit( true );
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


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

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:1081

        log.logDetailed( "Auto commit " + onOff );
      }
    } catch ( Exception e ) {
      if ( log.isDebug() ) {
        log.logDebug( "Can't turn auto commit " + onOff + Const.CR + Const.getStackTracker( e ) );
      }
    }
  }

  public void setCommitSize( int size ) {
    commitsize = size;
  }

  public void setAutoCommit( boolean useAutoCommit ) throws KettleDatabaseException {
    try {
      connection.setAutoCommit( useAutoCommit );
    } catch ( SQLException e ) {
      if ( useAutoCommit ) {
        throw new KettleDatabaseException( BaseMessages.getString(
          PKG, "Database.Exception.UnableToEnableAutoCommit", toString() ) );
      } else {
        throw new KettleDatabaseException( BaseMessages.getString(
          PKG, "Database.Exception.UnableToDisableAutoCommit", toString() ) );
      }
    }
  }

  /**
   * Perform a commit the connection if this is supported by the database
   */
  public void commit() throws KettleDatabaseException {
    commit( false );
  }

  public void commit( boolean force ) throws KettleDatabaseException {
    try {
      // Don't do the commit, wait until the end of the transformation.

View on GitHub (pinned to f3058517a1)