JDBC连接mysql8报错
发布日期:2021-10-06 15:05:14 浏览次数:10 分类:技术文章

本文共 901 字,大约阅读时间需要 3 分钟。

问题:org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is 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.

Caused by: 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.

**原因:**因使用的mysql版本为新版,连接参数需要加上时区

**解决:**新版的mysql驱动类更新成了

com.mysql.cj.jdbc.Driver

连接的时候也需要注意时区的问题,在url的连接参数上设置时区即可:我这里设置的是北京时区

url: jdbc:mysql:///test01?serverTimezone=GMT%2B8

转载地址:https://blog.csdn.net/m0_37815017/article/details/102534539 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Caused by: java.net.SocketTimeoutException: connect timed out
下一篇:idea中yml文件中输入没有提示

发表评论

最新留言

第一次来,支持一个
[***.219.124.196]2024年04月21日 03时37分30秒