java.sql.SQLException: Could not commit with auto-commit set on (PhysicalConnection.java:2356)

5.3k Views Asked by At

My web application start doesn't present error, but when i run it, I have this error...

None of my colleagues can help me, some of you?

i'm using websphere 7 on eclipse rational and java 1.6.0

E com.ibm.ws.webcontainer.webapp.WebApp logServletError SRVE0293E: [Errore servlet]-[action]: it.xxx.navigator.exception.NavigatorException: java.sql.SQLException: Could not commit with auto-commit set on
    at it.xxx.navigator.Navigator.throwException(Navigator.java:53)
    at it.xxx.navigator.Navigator.initialize(Navigator.java:217)
    at it.xxx.pensionis7.action.IndexAction.index(IndexAction.java:499)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)


Caused by: java.sql.SQLException: Could not commit with auto-commit set on
    at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:2356)
    at oracle.jdbc.driver.PhysicalConnection.commit(PhysicalConnection.java:2403)
    at oracle.jdbc.OracleConnectionWrapper.commit(OracleConnectionWrapper.java:139)
    at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.commit(WSJdbcConnection.java:1112)
    at it.xxx.navigator.dao.NavigatorConnection.commit(NavigatorConnection.java:46)
    at it.xxx.navigator.delegate.NavigatorBD.getDefinedApplications(NavigatorBD.java:78)
    at it.xxx.navigator.delegate.NavigatorDelegate.getDefinedApplications(NavigatorDelegate.java:33)
    at it.xxx.navigator.Navigator.initialize(Navigator.java:190)
    ... 35 more
1

There are 1 best solutions below

6
Pavel Smirnov On

Oracle's JDBC driver throws an exception when trying to commit withgetAutoCommit() == true.

So you either: use auto commit and do not call commit() at all (it'll be called automatically)

or

call commit() only when getAutoCommit() == false:

if (!connection.getAutoCommit()) {
    connection.commit();
}