java.sql.SQLException: Could not commit with auto-commit set on

Apache's JIRA Issue Tracker | Pat Fox | 2 years ago
  1. 0

    The oracle v12 driver throws the following exception if commit() is called on a connection that has auto-commit enabled(see [1]) . This seems to be a change in behaviour since v11. {code} caused by: java.sql.SQLException: Could not commit with auto-commit set on at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:4443) at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:4490) at org.apache.commons.dbcp.DelegatingConnection.commit(DelegatingConnection.java:334) at org.apache.commons.dbcp.DelegatingConnection.commit(DelegatingConnection.java:334) at org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.commit(PoolingDataSource.java:211) at org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter.doDropTables(DefaultJDBCAdapter.java:148) at org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.deleteAllMessages(JDBCPersistenceAdapter.java:534) ... 40 more {code} In the org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#doDropTables() it explicitly calls connection.commit() without checking if auto-commit is enabled. In other places auto-commit does seem to be checked before commit is called - org.apache.activemq.store.jdbc.TransactionContext#commit(). The v12 driver does allow autocommit-SpecCompliance to be turned off by setting system property "oracle.jdbc.autoCommitSpecCompliant=false". But it does seem like org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter#doDropTables() is not strictly adhering to the spec. I think it would be better to do a check if auto-commit is on before calling connection.commit(). I will attach a github pull request with test and potential fix - for someone to review.

    Apache's JIRA Issue Tracker | 2 years ago | Pat Fox
    java.sql.SQLException: Could not commit with auto-commit set on
  2. Speed up your debug routine!

    Automated exception search integrated into your IDE

  3. 0

    hibernate reestablish connection after being lost

    Stack Overflow | 2 years ago
    java.sql.SQLException: ORA-02396: exceeded maximum idle time, please connect again

    7 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.sql.SQLException

      Could not commit with auto-commit set on

      at oracle.jdbc.driver.PhysicalConnection.commit()
    2. Oracle jdbc
      PhysicalConnection.commit
      1. oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:4443)
      2. oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:4490)
      2 frames
    3. Commons DBCP
      PoolingDataSource$PoolGuardConnectionWrapper.commit
      1. org.apache.commons.dbcp.DelegatingConnection.commit(DelegatingConnection.java:334)
      2. org.apache.commons.dbcp.DelegatingConnection.commit(DelegatingConnection.java:334)
      3. org.apache.commons.dbcp.PoolingDataSource$PoolGuardConnectionWrapper.commit(PoolingDataSource.java:211)
      3 frames
    4. ActiveMQ :: Core
      JDBCPersistenceAdapter.deleteAllMessages
      1. org.apache.activemq.store.jdbc.adapter.DefaultJDBCAdapter.doDropTables(DefaultJDBCAdapter.java:148)
      2. org.apache.activemq.store.jdbc.JDBCPersistenceAdapter.deleteAllMessages(JDBCPersistenceAdapter.java:534)
      2 frames