File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Regarding autoCommit() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Regarding autoCommit()" Watch "Regarding autoCommit()" New topic

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?
Bosun Bello
Ranch Hand

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

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
Frank Carver

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 ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Moving to the JDBC forum.
I agree. Here's the link:
subject: Regarding autoCommit()
jQuery in Action, 3rd edition