This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes commit and rollback in transaction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "commit and rollback in transaction" Watch "commit and rollback in transaction" New topic

commit and rollback in transaction

manishkumarlal cs

Joined: Oct 25, 2005
Posts: 11
I need to execute a batch/transaction having a set of statements.I need to commit those statements which are executed successfully and the rest should be rolled back,is there any way to do it in java?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32645

Yes. There is a feature called autoCommit. Normally, statements are set to commit automatically after each one is run. You can set this to false and then explicitly call commit/rollback. Take a look at the Connection object for these methods.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: commit and rollback in transaction
It's not a secret anymore!