Subject Newbie Question: How do I create a transaction using JAVA+IB?
Author lapc2000br
Hi,

I'm trying to create a transaction using JAVA+IB but I'm not having
any success. I've tried:

//BEGIN TRANS
try {
conn.setAutoCommit(false);
conn.commit();
} catch (SQLException e) {}

//THE TRANS ITSELF
try {
Statement stmt1, stmt2;

stmt1 = conn.createStatement();
stmt1.executeUpdate("UPDATE..."));
stmt1.close();

stmt2 = conn.createStatement();
stmt2.executeUpdate("UPDATE..."));
stmt2.close();
} catch (SQLException e)
{
try {
conn.rollback();
} catch (SQLException e2) {
}
}

//END TRANS
try {
conn.commit();
conn.setAutoCommit(true);
} catch (SQLException e) {}

The problem occurs when the stmt1 is successful but stmt2 is NOT.
The transaction is NOT rolled back!

Can u help me?

Leo Cavalcanti.