ReplicationDriverhtml
針對Master/Slave,Mysql jdbc drivrer : ReplicationDrivermysql
https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-master-slave-replication-connection.htmlsql
http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-replication-connection.htmloracle
conn.setReadOnly(false);spa
conn.setReadOnly(true);orm
URL配置樣式:jdbc:mysql:replication://master,slave1,slave2,slave3/test?roundRobinLoadBalance=truehtm
幾種MySQL JDBC 驅動的URL前綴: get
URL_PREFIX = "jdbc:mysql://";it
REPLICATION_URL_PREFIX = "jdbc:mysql:replication://";io
MXJ_URL_PREFIX = "jdbc:mysql:mxj://";
LOADBALANCE_URL_PREFIX = "jdbc:mysql:loadbalance://";
jdbc:mysql:fabric://
https://docs.oracle.com/cd/E17952_01/mysql-utilities-1.4-en/connector-j-fabric-connect.html
另一種配置方式:
jdbc:mysql://address=(type=master)(host=master1host),address=(type=master)(host=master2host),address=(type=slave)(host=slave1host)/database
replication drivers舉例
jdbc:mysql:replication//master.amazonaws.com:3306,slave.amazonaws.com:3306/dbsid?failOverReadOnly=true;roundRobinLoadBalance=true&allowMasterDownConnections=true