| Author |
Cannot invoke a rollback operation when the AutoCommit mode is set to "true"
|
Arpit Aggarwal
Greenhorn
Joined: Feb 11, 2010
Posts: 4
|
|
I am using ScriptRunner class For running SQL scripts For SQL SERVER 2005 Data base. It is giving me following error for insertion queries other queries for deletion or selection is working fine.
com.microsoft.sqlserver.jdbc.SQLServerException: Cannot invoke a rollback operation when the AutoCommit mode is set to "true".
at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(Unknown Source)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.rollback(Unknown Source)
at com.ibatis.common.jdbc.ScriptRunner.runScript(ScriptRunner.java:222)
at com.ibatis.common.jdbc.ScriptRunner.runScript(ScriptRunner.java:114)
Please help what can be the issue.
Thanks
Arpit
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
|
Of course you can't rollback when autocommit is on. If you need rollback, you must turn autocommit off. Or use a transaction, which is a posh way of turning autocommit off.
|
 |
Arpit Aggarwal
Greenhorn
Joined: Feb 11, 2010
Posts: 4
|
|
|
Thanks Campbell, I tried with some <prop key="hibernate.connection.autocommit">false</prop> for doing auto commit false from my spring application context file. As well as tried to off auto commit of Database SQL SERVER 2005 by using command SET IMPLICIT_TRANSACTIONS { ON } but it is giving same error to me.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
Arpit Aggarwal wrote:Thanks Campbell, I tried with some <prop key="hibernate.connection.autocommit">false</prop> for doing auto commit false from my spring application context file. As well as tried to off auto commit of Database SQL SERVER 2005 by using command SET IMPLICIT_TRANSACTIONS { ON } but it is giving same error to me.
Don't you pass the autocommit property as a parameter in ScriptRunner's constructor?
|
JavaRanch FAQ HowToAskQuestionsOnJavaRanch
|
 |
Arpit Aggarwal
Greenhorn
Joined: Feb 11, 2010
Posts: 4
|
|
Thanks Paul, I was pasing wrong parameter in ScriptRunner's constructor once i changed:
scriptRunner = new ScriptRunner(con, true, true);
To
scriptRunner = new ScriptRunner(con, false, true);
Its working fine for me
Thanks a lot for your help Paul, Campbell.
|
 |
Paul Sturrock
Bartender
Joined: Apr 14, 2004
Posts: 10336
|
|
You are welcome
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32611
|
|
Paul Sturrock wrote:You are welcome
Agreed
|
 |
 |
|
|
subject: Cannot invoke a rollback operation when the AutoCommit mode is set to "true"
|
|
|