This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes SavePoint in JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SavePoint in JDBC" Watch "SavePoint in JDBC" New topic
Author

SavePoint in JDBC

Santosh Maskar
Ranch Hand

Joined: Jul 02, 2003
Posts: 226
Hi,
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

code
insert
update
savepoint save1

insert
rollback

then it will rollback the transaction upto savepoint

i need to roll back from first

how i can do this.


Regards
Santosh
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.

Jules
Santosh Maskar
Ranch Hand

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

Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: SavePoint in JDBC
 
Similar Threads
Multiple updates
Savepoints and transactions
rollback transaction for single phase commit
I have name of a savepoint, can i rollback to that savepoint?
Query about rollback() method