This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes JDBC and the fly likes Regarding autoCommit() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Regarding autoCommit()" Watch "Regarding autoCommit()" New topic
Author

Regarding autoCommit()

Sajee Joseph
Ranch Hand

Joined: Jan 17, 2001
Posts: 200
Hello all,
In my servlet application, i have an setAutoCommit(false) statement. I use this to control the commits & rollbacks. is it necessary to set back the autoCommit to true after the commit or rollback is done?
Thanks,
Sajee
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
If you have other logic that you want to be comitted automatically, I would say yes.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
Originally posted by Sajee Joseph:
is it necessary to set back the autoCommit to true after the commit or rollback is done?

I guess to avoid underiable outcome with the buffer, u have to set it back to autocommit to true... It's better to accept the default implementation of the API, if you don't need to deal with special things on it...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
Strictly, you should check that it isn't already set to false before you really set it, and only set it "back" to true if it was true before your code.
You can get yourself in some really sticky situations if you set something "back" to what it wasn't!


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

Moving to the JDBC forum.
 
Don't get me started about those stupid light bulbs.
 
subject: Regarding autoCommit()
 
Similar Threads
How can i close a connection to Access97?
Is there a begintrans in Java?
storing date in mysql
Auto commit???
how to configure autocommit in Webshpere application server