// so there is nothing more to do.
}
}
} catch (javax.transaction.xa.XAException xae)
{ // Distributed transaction failed, so roll it back.
// Report XAException on prepare/commit.
System.out.println("Distributed transaction prepare/commit failed. " +
"Rolling it back.");
System.out.println("XAException error code="+xae.errorCode);
System.out.println("XAException message="+xae.getMessage());
xae.printStackTrace();
try
{
xares1.rollback(xid1);
}
catch (javax.transaction.xa.XAException xae1)
{ // Report failure of rollback.
System.out.println("distributed Transaction rollback xares1 failed");
System.out.println("XAException error code="+xae1.errorCode);
System.out.println("XAException message="+xae1.getMessage());
}
try
{
xares2.rollback(xid1);
}
catch (javax.transaction.xa.XAException xae2)
{ // Report failure of rollback.
System.out.println("distributed Transaction rollback xares2 failed");
System.out.println("XAException error code="+xae2.errorCode);
System.out.println("XAException message="+xae2.getMessage());
}
}
try
{
conn1.close();
xaconn1.close();
}
catch (Exception e)
{
System.out.println("Failed to close connection 1: " + e.toString());
e.printStackTrace();
}
try
{
conn2.close();
xaconn2.close();
}
catch (Exception e)
{
System.out.println("Failed to close connection 2: " + e.toString());
e.printStackTrace();
}
}
catch (java.sql.SQLException sqe)
{
System.out.println("SQLException caught: " + sqe.getMessage());
sqe.printStackTrace();
}
catch (javax.transaction.xa.XAException xae)
{
System.out.println("XA error is " + xae.getMessage());
xae.printStackTrace();
}
catch (javax.naming.NamingException nme)
{
Chapter 12. IBM Data Server Driver for JDBC and SQLJ type 4 connectivity JDBC and SQLJ distributed transaction support 471