• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Cannot invoke a rollback operation when the AutoCommit mode is set to "true"

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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?
 
Arpit Aggarwal
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are welcome
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Paul Sturrock wrote:You are welcome

Agreed
 
please buy this thing and then I get a fat cut of the action:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic