private boolean isSQLErrorTransient ( SQLException sqlex ) { if ( tc . isEntryEnabled ( ) ) Tr . entry ( tc , "isSQLErrorTransient " , new Object [ ] { sqlex , this } ) ; boolean retryBatch = false ; int sqlErrorCode = sqlex . getErrorCode ( ) ; if ( tc . isEventEnabled ( ) ) { Tr . event ( tc , " SQL exception:" ) ; Tr . event ( tc , " Message: " + sqlex . getMessage ( ) ) ; Tr . event ( tc , " SQLSTATE: " + sqlex . getSQLState ( ) ) ; Tr . event ( tc , " Error code: " + sqlErrorCode ) ; } for ( int transientCode : _sqlTransientErrorCodes ) { Tr . event ( tc , "Test against stored code: " + transientCode ) ; if ( transientCode == sqlErrorCode ) { Tr . event ( tc , "TRANSIENT: A connection failed but could be reestablished, retry." ) ; retryBatch = true ; break ; } } if ( ! retryBatch && sqlex instanceof BatchUpdateException ) { BatchUpdateException buex = ( BatchUpdateException ) sqlex ; Tr . event ( tc , "BatchUpdateException: Update Counts - " ) ; int [ ] updateCounts = buex . getUpdateCounts ( ) ; for ( int i = 0 ; i < updateCounts . length ; i ++ ) { Tr . event ( tc , " Statement " + i + ":" + updateCounts [ i ] ) ; } SQLException nextex = buex . getNextException ( ) ; while ( nextex != null ) { sqlErrorCode = nextex . getErrorCode ( ) ; if ( tc . isEventEnabled ( ) ) { Tr . event ( tc , " SQL exception:" ) ; Tr . event ( tc , " Message: " + nextex . getMessage ( ) ) ; Tr . event ( tc , " SQLSTATE: " + nextex . getSQLState ( ) ) ; Tr . event ( tc , " Error code: " + sqlErrorCode ) ; } for ( int transientCode : _sqlTransientErrorCodes ) { Tr . event ( tc , "Test against stored code: " + transientCode ) ; if ( transientCode == sqlErrorCode ) { Tr . event ( tc , "TRANSIENT: A connection failed but could be reestablished, retry." ) ; retryBatch = true ; break ; } } nextex = nextex . getNextException ( ) ; } } if ( tc . isEntryEnabled ( ) ) Tr . exit ( tc , "isSQLErrorTransient" , retryBatch ) ; return retryBatch ; }
Determine whether we have encountered a potentially transient SQL error condition . If so we can retry the SQL .