aspose file tools*
The moose likes JDBC and the fly likes Commit & Rollback using java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Commit & Rollback using java?" Watch "Commit & Rollback using java?" New topic
Author

Commit & Rollback using java?

Jignesh Gohel
Ranch Hand

Joined: Dec 28, 2004
Posts: 276
Hi,

I have a stored procedure in which i have four insert statements .Now i want to commit each insert statement if it gets successfully executed .By chance if any exception occurs while doing any particular insert i want to rollback each of the inserts so that atomicity exists in the tables.

So how to do this through my java code & where these methods or constants for commit & rollback shoul be written when using the CallableStatement???


Thanks,
Jignesh
[ April 04, 2006: Message edited by: Bear Bibeault ]

Regards,
Jignesh

The Art Of Life Is To Know When To Be Useless And When To Be Useful - CHUANG TZU
Mattias Arthursson
Ranch Hand

Joined: Jul 26, 2004
Posts: 90
You'll want to call setAutoCommit(false) on the Connection before doing anything else. Once you're done with your statements, call commit() or rollback() (on the Connection) respectively.


Admit nothing. Blame everyone. Be bitter.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Commit & Rollback using java?