• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to ensure this transaction is atomic?

 
Jacky Luk
Ranch Hand
Posts: 634
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


If this method accidentally interrupted, then it must rollback the whole
trasnaction, where should I add this capability to this method?
Thanks
Jack
 
Rob Spoor
Sheriff
Pie
Posts: 20745
68
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Turn off auto commit for the connection at the start of the method, then end with either a commit() or rollback(). I usually leave the connection in the state I received it in, so that would also mean setting the auto commit value back to the original value.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic