Description:
I check that the FailoverConnectionProxy do failover when any exception happends, but sometimes I just want let it failover just when some given conditions, like some SQLException like the load balancing JDBC driver.
How to repeat:
JDBC URL,
"jdbc:mysql://10.228.169.99:3306,10.228.169.100:3306/rad_wifi?user=aicent&password=aicent&allowMasterDownConnections=false&autoReconnectForPools=true&secondsBeforeRetryMaster=10&failOverReadOnly=false&loadBalanceExceptionChecker=com.aicent.wifi.jdbc.ha.MyLoadBalanceExceptionChecker&retriesAllDown=10";
note that, it is a failOver JDBC, not the load balancing JDBC.
not the prefix, jdbc:mysql:loadbalance://
Suggested fix:
File: FailoverConnectionProxy.java
Method:
synchronized void dealWithInvocationException(InvocationTargetException e)
Improvement:
if (t != null) {
if (this.failedOver) { // try and fall back
createPrimaryConnection();
if (this.currentConn != null) {
throw t;
}
}
failOver();
throw t;
}
changed to,
if (t != null) {
if (t instanceof SQLException && shouldExceptionTriggerFailover((SQLException) t)) {
if (this.failedOver) { // try and fall back
createPrimaryConnection();
if (this.currentConn != null) {
throw t;
}
}
failOver();
}
throw t;
}