这样使用:
jdbc:mysql://[host:port],[host:port].../[database][?propertyname1][=propertyvalue1][&propertyname2][=propertyvalue2]...
例如:
jdbc:mysql://host1:3306,host2:3307,host3:3308/test?user=root&password=root&autoreconnect=true&failoverreadonly=false
注意:
我在使用的时候发现一个问题,当使用3.0.14版本的jdbc时,使用上述方法出现异常:
java.sql.sqlexception: server connection failure during transaction.
attempted reconnect 3 times. giving up.
... ...
在更新到3.0.15版本后问题没有出现,这可能是3.0.14这个版本的一个bug。
闽公网安备 35060202000074号