這樣使用:
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。
|
新聞熱點
疑難解答