Documentation Home
MySQL Utilities 1.5 Manual
Related Documentation Download this Manual
PDF (US Ltr) - 1.5Mb
PDF (A4) - 1.5Mb
HTML Download (TGZ) - 289.5Kb
HTML Download (Zip) - 301.7Kb

MySQL Utilities 1.5 Manual  /  ...  /  How Connector/J Chooses a MySQL Server

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:

  • server group name: If a server group name is specified directly, it is used.

  • shard table: If a shard table is given, the global group for the shard mapping governing the given shard table is used.

  • shard table + shard key: If a shard key is given the shard mapping is used to determine which server group handles data for the shard key.

  • query tables: If the query table set contains a sharded table, the shard mapping for that table is used.

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.

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