*/
static RuntimeException convertException(
Exception e, boolean convertTxnExceptions)
{
if (convertTxnExceptions && e instanceof LockNotGrantedException) {
return new TransactionTimeoutException(
"Transaction timed out: " + e.getMessage(), e);
} else if (convertTxnExceptions && e instanceof DeadlockException) {
return new TransactionConflictException(
"Transaction conflict: " + e.getMessage(), e);
} else if (e instanceof RunRecoveryException) {
/*
* It is tricky to clean up the data structures in this instance in
* order to reopen the Berkeley DB databases, because it's hard to
* know when they are no longer in use. It's OK to catch this
* Error and create a new environment instance, but this instance
* is dead. -tjb@sun.com (10/19/2006)
*/
Error error = new Error(
"Database requires recovery -- need to restart: " + e, e);
logger.logThrow(Level.SEVERE, error, "Database requires recovery");
throw error;
} else if (e instanceof XAException) {
int errorCode = ((XAException) e).errorCode;
if (errorCode == XA_RBTIMEOUT) {
throw new TransactionTimeoutException(
"Transaction timed out: " + e.getMessage(), e);
} else if (errorCode == XA_RBDEADLOCK) {
throw new TransactionConflictException(
"Transaction conflict: " + e.getMessage(), e);
} else if (errorCode >= XA_RBBASE && errorCode <= XA_RBEND) {