The server time zone value'???ú±ê×??±??' 与Loading class com.mysql.jdbc.Driver'. This is deprecated.

MySQL最近遇到的两点问题—Cause: java.sql.SQLException: The server time zone value与Loading class com.mysql.jdbc.Driver’. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver

第一个问题Cause: java.sql.SQLException: The server time zone value
在查询数据库数据时报错:Cause: 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 (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
意思是:服务器时区值不能识别或代表了多个时区,如果要利用时区支持,必须要配置服务器或JDBC驱动(通过serverTimezone属性)一个具体的时区值。

解决方法:在数据库连接的配置文件中,url后加上:?serverTimezone=GMT%2B8 或 serverTimezone=GMT 或 serverTimezone=UTC
UTC为协调世界时,又称世界统一时间。GMT为格林尼治标准时间,GMT%2B8代表东八区(GMT+8),%2B代表+,这是因为在URL地址中,只能包含特定的原始字符,其他字符,包括中文等会被编码。

第二个问题Loading class com.mysql.jdbc.Driver’. This is deprecated. The new driver class is com.mysql.cj.jdbc.Driver
com.mysql.jdbc.Driver已经不再支持使用了,最新的MySQL连接驱动为com.mysql.cj.jdbc.Driver

解决方法:将com.mysql.jdbc.Driver更换为 com.mysql.cj.jdbc.Driver即可。

链接1:http://www.cnblogs.com/zxxsteven/p/9485600.html
链接2:https://blog.csdn.net/weixin_40916641/article/details/80546040

你可能感兴趣的:(MySQL)