Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes JDBC and Relational Databases and the fly likes SavePoint in JDBC 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 "SavePoint in JDBC" Watch "SavePoint in JDBC" New topic

SavePoint in JDBC

Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
I had set the save point in my code after 2 insert statment , when i will rollback the transaction then it will roll back up to save point , now i need to roll back all the trancastion , i mean i need to rollback the transaction from begining , (before the savepoint) can i do this

savepoint save1


then it will rollback the transaction upto savepoint

i need to roll back from first

how i can do this.

Julian Kennedy
Ranch Hand

Joined: Aug 02, 2004
Posts: 823
There are two overloaded versions of Connection.rollback(). The one that takes a Savepoint argument should rollback the transaction to the specified Savepoint; the other one should rollback the whole transaction, i.e. to the last commit point. You need to ensure you have setAutoCommit(false).

If that doesn't work for some reason you could try calling releaseSavePoint() before your rollback.

Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Its working as per your tips

I agree. Here's the link:
subject: SavePoint in JDBC
It's not a secret anymore!