This week's book giveaway is in the Android forum.
We're giving away four copies of Android Programming: The Big Nerd Ranch Guide and have Bill Phillips & Chris Stewart on-line!
See this thread for details.
Win a copy of Android Programming: The Big Nerd Ranch Guide this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

what if jdbc commit throws exception in a loop ?  RSS feed

 
Csaba Szegedi
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

I have a loop with db modifications and every loop ended with commit.

What if a commit throws exception ? As I know we must try to rollback.
But do we need to continue the loop ?

As for me I would exit from the function with a return false (after the connection.close) or what ever, forcing the further db modifications is pointles then.
Is this would be the best way or exists another ?

Thanks for your suggestion in advance.


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 36875
481
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's going to depend on your requirements. If you want to rollback the whole thing on failure, you wouldn't commit each time through the loop - only at the end.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!