Documentation Home
MySQL Connector/J 8.0 Developer Guide
Related Documentation Download this Manual
PDF (US Ltr) - 454.6Kb
PDF (A4) - 457.8Kb
HTML Download (TGZ) - 112.2Kb
HTML Download (Zip) - 135.2Kb


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

Pre-General Availability Draft: 2018-01-15

9.2 Configuring Client-Side Failover when using the X Protocol

When using the X Protocol, Connector/J (since release 6.0.5) 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:

mysqlx://sandy:mypassword@[host1:33060,host2:33061]/test

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

mysqlx://sandy:mypassword@[(address=host1:33060,priority=2),(address=host2:33061,priority=1)]/test

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.


User Comments
Sign Up Login You must be logged in to post a comment.