MySQL Problems

用Eclipse編寫Java Project用到了MySQL數據庫後出現了一些問題如下:

1 `com.mysql.jdbc.Driver’. This is deprecated. The new driverclass is `com.mysql.cj.jdbc.Driver’.

這個是因爲使用了新版的MySQL Connector的原因
這裏寫圖片描述

問題解決

下面已經提示了我們需要使用`com.mysql.cj.jdbc.Driver’,那麼我們就改成這個就好了;

2 Thu Sep 13 14:39:20 CST 2018 WARN: Establishing SSL connection without server’s identity verification is not recommended.

這個是一個警告,不影響結果的
這裏寫圖片描述

問題解決

在原來的數據庫名稱後添加

?useUnicode=true&characterEncoding=utf-8&useSSL=false

例如我的原版

String url = "jdbc:mysql://localhost:3306/db_book"

修改後爲

String url = "jdbc:mysql://localhost:3306/db_book?useUnicode=true&characterEncoding=utf-8&useSSL=false“

3 java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver

這個是MySQL的時區問題需要設置
這裏寫圖片描述

問題解決

1 打開MySQL的命令行模式,並輸入如下命令

show variables like "%time_zone";

這裏寫圖片描述

2 修改時區

set global time_zone="+8:00";

這裏寫圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章