用java通過jdbc串連mysql資料庫總結

來源:互聯網
上載者:User

標籤: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資料庫總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.