• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Issue while commiting to the DB "you cannot commit with autocommit set to true"

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

My application is running in jboss5.0 app server.
I am trying to save information to different tables in an oracle database.

In order to do that we are actually setting the connection’s setautoCommit() method with a false value.

Then calls all the insert/update statements to diff tables. After that we are calling the connections. commit() & then again we are setting the setautoCommit() method with a true value.

During runtime I am getting the following error
ERROR [STDERR] java.sql.SQLException: You cannot commit with autocommit set!

I am using a <local-tx-datasource>. I haven’t specified any auto commit attribute in my data source definition.


Can some one tell me what could be the issue & how can I resolve this.

Appreciate your help


Regards
Harikrishnan
 
Author
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't call the setautoCommit() method at all and see what happens. You should really always manage your transaction, so you should have no need to turn it on.

Are you using straight JDBC in your code?
 
Rajesh Unnithan
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using straight forward jdbc call only.

If I am not going to use the set autocomit false. By default the setAutoComit is true and after each query execution, it will commit. For ex. I have four separate insert statement. If I am not using the setAutocomit false initially, then after every single insert statement, jboss will call the commit. In this scenario, if I have an exception occurred in the four the insert statement. I cannot rollback the first three inserts which are already committed. What I really want is if the exception occurred in the forth insert, it should roll back all the four.

Hope you understood my problem.


Regards
Harikrishnan
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic