MySQL Connector/J 8.0 Developer Guide

6.13 Support for DNS SRV Records

Connector/J supports the use of DNS SRV records for connections since release 8.0.19. For information about DNS SRV support in MySQL, see Connecting to the Server Using DNS SRV Records.

When multiple MySQL instances provide the same service for your applications, DNS SRV records can be used to provide failover, load balancing, and replication services. They eliminate the need for clients to identify each possible host in the connection string, or for connections to be handled by an additional software component. Here is a summary for Connector/J's support for DNS SRV records:

Here are some requirements and restrictions on the DNS SRV record support by Connector/J:

DNS SRV Record Support for Load Balancing and Failover.  For load-balancing and failover connections, Connector/J uses the priority field of the DNS SRV records to decide on the priorities for connection attempts for hosts.

DNS SRV Record Support for Connection Pooling.  In an X DevAPI connection pooling setup, Connector/J re-queries the DNS SRV records regularly and phases out gracefully any connections whose hosts no longer appear in the records, and readmits the connections into the pool when their hosts reappear in the records.

Looking up DNS SRV Records.  It is the users' responsibility to provide a full service host name; Connector/J does not append any prefix nor validate the host name structure. The following are examples of valid service host name patterns:

See Connections Using DNS SRV Records in the X DevAPI User Guide for details.