public static SQLException toSQLException ( ResourceException resX ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "toSQLException" , resX ) ; SQLException sqlX = null ; for ( Throwable linkedX = resX ; linkedX != null ; linkedX = getChainedException ( linkedX ) ) { if ( linkedX instanceof SQLException ) { sqlX = ( SQLException ) linkedX ; break ; } // The J2C connection manager raises a special exception subclass. else if ( linkedX instanceof ResourceAllocationException && linkedX . getClass ( ) . getName ( ) . equals ( "com.ibm.websphere.ce.j2c.ConnectionWaitTimeoutException" ) ) { // Use a special SQLException subclass for connection wait timeout. sqlX = new ConnectionWaitTimeoutException ( linkedX . getMessage ( ) ) ; sqlX . initCause ( resX ) ; sqlX = new SQLTransientConnectionException ( linkedX . getMessage ( ) , "08001" , 0 , sqlX ) ; break ; } } // If neither the original exception nor any of the chained exceptions were found to // be SQLExceptions or ConnectionWaitTimeoutExceptions, just convert the original // exception to a SQLException. if ( sqlX == null ) { // use the original exception to create a SQL Exception if ( tc . isEventEnabled ( ) ) Tr . event ( tc , "Converting ResourceException to a SQLException" ) ; sqlX = new SQLException ( resX . getMessage ( ) ) ; sqlX . initCause ( resX ) ; } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "toSQLException" , getStackTraceWithState ( sqlX ) ) ; return sqlX ; }
Converts a ResourceException to a SQLException . Returns the first chained exception found to be a SQLException or ConnectionWaitTimeoutException . If none of the chained chained exceptions are SQLExceptions or ConnectionWaitTimeoutExceptions a new SQLException is created containing information from the ResourceException .