標籤:0.11 ica and 第一個 zone 參數 版本 www. without
參網站:1、https://www.cnblogs.com/centor/p/6142775.html
2、53378755
3、52292099
首先參考上面的網站下載:
MySQL串連驅動:mysql-connector-java-8.0.11。
根據參考網站教程在項目中加入串連驅動包。
然後複製網站1的代碼運行後出現錯誤。
Loading class `com.mysql.jdbc.Driver‘. This is deprecated. 和
WARN: Establishing SSL connection without server‘s identity verification is not recommended.
According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn‘t set.
和 The server time zone value ‘???ú±ê×??±??‘ is unrecognized or represents more than one time zone.
網上查了查,
第一個錯誤:這個錯誤比較好解決,把com.mysql.jdbc.Driver修改為com.mysql.cj.jdbc.Driver。
第二個錯誤:是目前的版本的MySQL要求使用SSL,
第三個錯誤:需要在Url後面添加一個參數:
所以把:String url = "jdbc:mysql://localhost:3306/user_password"; 做出如下修改即可:
String url = "jdbc:mysql://localhost:3306/user_password?serverTimezone=UTC&useSSL=false ";
知識點補充:
連接器驅動參考文檔:https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference.html
http://elf8848.iteye.com/blog/1684414
用java通過jdbc串連mysql資料庫總結