Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.sql.SQLException: Could not commit with auto-commit set on at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:4443)

Tags:

java

oracle

jdbc

I just upgrade to new jdbc driver from classes12.jar to ojdbc7.jar

My app threw an exception when was running with ojdbc7.jar:

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 oracle.jdbc.driver.T4CConnection.doSetAutoCommit(T4CConnection.java:943)
    at oracle.jdbc.driver.PhysicalConnection.setAutoCommit(PhysicalConnection.java:4

My app still run normally with classes12.jar.

I researched on oracle:

This exception is raised for any one of the following cases:

  • When auto-commit status is set to true and commit or rollback method is called
  • When the default status of auto-commit is not changed and commit or rollback method is called
  • When the value of the COMMIT_ON_ACCEPT_CHANGES property is true and commit or rollback method is called after calling the acceptChanges method on a rowset

But i couldn't find mistake in my source. Please help me give more explaination about this error.

like image 563
scarework Avatar asked May 30 '14 11:05

scarework


People also ask

How do I turn off Autocommit in Oracle SQL Developer?

Turn off the auto commit option in SqlDeveloper. Go to Tools -> Preferences -> Database -> ObjectViewer Parameters and uncheck the box Set Auto Commit On.

Does JDBC automatically commit a transaction?

By default, JDBC uses an operation mode called auto-commit. This means that every update to the database is immediately made permanent. Any situation where a logical unit of work requires more than one update to the database cannot be done safely in auto-commit mode.

Is insert Autocommit in Oracle?

Oracle SQL DELETE and SQL INSERT Statements do not auto commit (patch issue)


1 Answers

The latest OJDBC drivers are more compliant then they where. You can turn off this behavior for legacy code:

-Doracle.jdbc.autoCommitSpecCompliant=false

It's a JVM option.

like image 193
Olafur Tryggvason Avatar answered Oct 17 '22 02:10

Olafur Tryggvason