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

本文解决MySQL连接中因时区配置不当导致的错误,及旧版驱动com.mysql.jdbc.Driver的替代方案,确保数据库连接稳定。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.youkuaiyun.com/weixin_40916641/article/details/80546040

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值