Win a copy of Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications this week in the Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to ensure this transaction is atomic?  RSS feed

 
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
Posts: 21116
85
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
Boost this thread!