Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Commit & Rollback using java?

 
Jignesh Gohel
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a stored procedure in which i have four insert statements .Now i want to commit each insert statement if it gets successfully executed .By chance if any exception occurs while doing any particular insert i want to rollback each of the inserts so that atomicity exists in the tables.

So how to do this through my java code & where these methods or constants for commit & rollback shoul be written when using the CallableStatement???


Thanks,
Jignesh
[ April 04, 2006: Message edited by: Bear Bibeault ]
 
Mattias Arthursson
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll want to call setAutoCommit(false) on the Connection before doing anything else. Once you're done with your statements, call commit() or rollback() (on the Connection) respectively.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic