Class name and JDBC URL format
Class name com.mysql.jdbc.driver
[] Represents options
The URL format is: jdbc: mysql: // [host name] [fail over host] [: port] / [database] [? property] = [attribute value] [& property] = [attribute value]
The host name is 127.0.0.1, and the port defaults to 3306. Starting from 3.0.12 Connector / J supports multi-host and ports, just put them with a comma.
If the database connection will not be specified, you or call the setCatalog () method in the current connection; send the 'Use dbname' query or use the completed table name in the SQL statement. It is not the best way to indicate that it is the best way when the multi-database operation is performed.
MySQL CConnector / J supports failover. It allows you to drive and perform read-only queries in multiple backups. Fault switches only occurs in the case where the connection is automatically submitted, since the failover is not reliable during the transaction process. The failover function has the following behavior: If the URL's "AutoreConnect" property is false: Fault switch only occurs when the connection is initialized, the driver determines that the first host can be restored again. If the URL's "AutoreConnect" property is true: When the driver determines that the connection has been invalid (before each query), the switch is handoff, and the first host can be restored (after the query, before the query, the primary query Already sent). In any case
As long as you connect to a fault recovery server, the connection will be set to read-only, so modifying the query will rager the exception (the query will be processed by the MySQL server).