@ Override public void throwFailoverMessage ( HostAddress failHostAddress , boolean wasMaster , SQLException queryException , boolean reconnected ) throws SQLException { String firstPart = "Communications link failure with " + ( wasMaster ? "primary" : "secondary" ) + ( ( failHostAddress != null ) ? " host " + failHostAddress . host + ":" + failHostAddress . port : "" ) + ". " ; String error = "" ; if ( reconnected ) { error += " Driver has reconnect connection" ; } else { if ( currentConnectionAttempts . get ( ) > urlParser . getOptions ( ) . retriesAllDown ) { error += " Driver will not try to reconnect (too much failure > " + urlParser . getOptions ( ) . retriesAllDown + ")" ; } } String message ; String sqlState ; int vendorCode = 0 ; Throwable cause = null ; if ( queryException == null ) { message = firstPart + error ; sqlState = CONNECTION_EXCEPTION . getSqlState ( ) ; } else { message = firstPart + queryException . getMessage ( ) + ". " + error ; sqlState = queryException . getSQLState ( ) ; vendorCode = queryException . getErrorCode ( ) ; cause = queryException . getCause ( ) ; } if ( sqlState != null && sqlState . startsWith ( "08" ) ) { if ( reconnected ) { //change sqlState to "Transaction has been rolled back", to transaction exception, since reconnection has succeed sqlState = "25S03" ; } else { throw new SQLNonTransientConnectionException ( message , sqlState , vendorCode , cause ) ; } } throw new SQLException ( message , sqlState , vendorCode , cause ) ; }
Throw a human readable message after a failoverException .