Documentation Home
MySQL Connector/J 8.0 Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 483.0Kb
PDF (A4) - 485.0Kb
HTML Download (TGZ) - 117.5Kb
HTML Download (Zip) - 136.3Kb

MySQL Connector/J 8.0 Developer Guide  /  Multi-Host Connections  /  Configuring Client-Side Failover when using the X Protocol

9.2 Configuring Client-Side Failover when using the X Protocol

When using the X Protocol, Connector/J supports a client-side failover feature for establishing a Session. If multiple hosts are specified in the connection URL, when Connector/J fails to connect to a listed host, it tries to connect to another one. This is a sample X DevAPI URL for configuring client-side failover:


An alternate format can also be used, with which the priority for connection can be set explicitly for each individual host:


With the client-side failover configured, when there is a failure to establish a connection, Connector/J keeps attempting to connect to a host on the host list in the order of the set priorities for the hosts, which are specified by any numbers between 0 to 100, with a larger number indicating a higher priority for connection. Priorities should either be set for all or no hosts. When no priorities are specified, the priorities for connection are established according to the order the hosts appear in the list, with a host appearing earlier in the list receiving a higher priority.

Notice that this feature only allows for a failover when Connector/J is trying to establish a connection, but not during operations after a connection has already been made.