| Author |
what if jdbc commit throws exception in a loop ?
|
Csaba Szegedi
Ranch Hand
Joined: Mar 27, 2010
Posts: 36
|
|
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
internet detective
Marshal
Joined: May 26, 2003
Posts: 26200
|
|
|
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.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
 |
|
|
subject: what if jdbc commit throws exception in a loop ?
|
|
|