MySQL Connector/J size='-1'>5.0.8

com.mysql.jdbc
Class LoadBalancingConnectionProxy

java.lang.Object
  extended by com.mysql.jdbc.LoadBalancingConnectionProxy
All Implemented Interfaces:
PingTarget, java.lang.reflect.InvocationHandler

public class LoadBalancingConnectionProxy
extends java.lang.Object
implements java.lang.reflect.InvocationHandler, PingTarget

An implementation of java.sql.Connection that load balances requests across a series of MySQL JDBC connections, where the balancing takes place at transaction commit. Therefore, for this to work (at all), you must use transactions, even if only reading data. This implementation will invalidate connections that it detects have had communication errors when processing a request. A new connection to the problematic host will be attempted the next time it is selected by the load balancing algorithm. This implementation is thread-safe, but it's questionable whether sharing a connection instance amongst threads is a good idea, given that transactions are scoped to connections in JDBC.

Version:
$Id: $

Nested Class Summary
protected  class LoadBalancingConnectionProxy.ConnectionErrorFiringInvocationHandler
           
 
Method Summary
 void doPing()
           
 java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
          Proxies method invocation on the java.sql.Connection interface, trapping "close", "isClosed" and "commit/rollback" (to switch connections for load balancing).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

invoke

public java.lang.Object invoke(java.lang.Object proxy,
                               java.lang.reflect.Method method,
                               java.lang.Object[] args)
                        throws java.lang.Throwable
Proxies method invocation on the java.sql.Connection interface, trapping "close", "isClosed" and "commit/rollback" (to switch connections for load balancing).

Specified by:
invoke in interface java.lang.reflect.InvocationHandler
Throws:
java.lang.Throwable

doPing

public void doPing()
            throws java.sql.SQLException
Specified by:
doPing in interface PingTarget
Throws:
java.sql.SQLException

MySQL Connector/J size='-1'>5.0.8