8.9.8 How Connector/J Chooses a MySQL Server

Before a database server can be chosen, a server group must be chosen. The following values are taken into account:

The server group name can be accessed by con.getCurrentServerGroup().getName().

Once a server group is chosen, an individual database server is chosen based on the read-only state of the connection. A read-only server is chosen if one is available. Otherwise a read-write server is chosen. The server weight is not currently taken into account.

None of these values can be changed while a transaction is in progress.