// This is the first use of the connection in this transaction, so we must
// enlist it in the transaction
Transaction transaction = getTransaction();
try {
XAResource xaResource = transactionRegistry.getXAResource(sharedConnection);
transaction.enlistResource(xaResource);
} catch (RollbackException e) {
// transaction was rolled back... proceed as if there never was a transaction
} catch (SystemException e) {
throw (SQLException) new SQLException("Unable to enlist connection the transaction").initCause(e);
}