java.sql.SQLException: Could not commit with auto-commit set on
This kind of exceptions occur when the Oracle JDBC Driver (ojdbc6.jar) version 12 or above will be used. Version 12 and above of the driver is more strictly than earlier driver versions.
You can solve the problem, you have few options:
- Change jar file to old version.( Below 12; usually issue occurs while migrating to new server)
-
Override behavior of new jar version(ojdbc6.jar) with setting below JVM arguments.
-Doracle.jdbc.autoCommitSpecCompliant=false
-
Set Auto Commit off in Java/SQL:
Java:
conn.setAutoCommit(false);
Oracle:
SET AUTOCOMMIT OFF
其中 第二个方法 被证实有效。
参考 http://stackoverflow.com/questions/23953534/java-sql-sqlexception-could-not-commit-with-auto-commit-set-on-at-oracle-jdbc-d