Re: Rollback not working
- From: "joeNOSPAM@xxxxxxx" <joe.weinstein@xxxxxxxxx>
- Date: 11 May 2007 08:29:09 -0700
Ok, then your savepoint stuff is irrelevant. You are doing a simple
series of transactions, each one being a simple execution of the
prepared statement. Because your transaction is a single statement,
you don't even need to mess with autoCommit:
for (Iterator iter = burstAssignments.iterator(); iter.hasNext(); )
{
try {
pStmt.setInt(1, valSentId.intValue());
pStmt.setInt(2, burstAssignment.getId().intValue());
pStmt.execute(); // if it succeeds it is committed, else it
is not.
}
catch (Exception ex) {
ex.printStackTrace();
}
if you have any other code that wants a multi-statement tx, then it's:
con.setAutoCommit(false);
boolean didAnythingThatWeNeedToRollback;
for (Iterator iter = burstAssignments.iterator(); iter.hasNext(); )
{
try {
didAnythingThatWeNeedToRollback = false;
// do first update...
pStmt.setInt(1, valSentId.intValue());
pStmt.setInt(2, burstAssignment.getId().intValue());
pStmt.execute();
didAnythingThatWeNeedToRollback = true;
// do subsequent updates
pStmt2.setInt(1, ...);
pStmt2.execute();
con.commit();
}
catch (Exception ex) {
if (didAnythingThatWeNeedToRollback) con.rollback();
ex.printStackTrace();
}
Joe Weinstein at BEA Systems.
.
- References:
- Rollback not working
- From: bcr666
- Re: Rollback not working
- From: joeNOSPAM@xxxxxxx
- Re: Rollback not working
- From: bcr666
- Rollback not working
- Prev by Date: Re: Rollback not working
- Next by Date: Need Help : taking data from JSP page and putting in MySQL database
- Previous by thread: Re: Rollback not working
- Next by thread: Need help : degrading performance in record updates
- Index(es):