Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SavePoint in JDBC

 
Santosh Maskar
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Its working as per your tips

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic