doubleyong
管理员
管理员
  • 最后登录2024-04-24
  • 发帖数1167
  • 最爱沙发
  • 喜欢达人
  • 原创写手
  • 社区居民
  • 忠实会员
阅读:187回复:0

[Java EE]使用JDBC连接MySql时报错:You must configure either the server or JDBC driver (via the serverTimezone cconfig

楼主#
更多 发布于:2024-04-12 10:41
问题:在springboot 中,使用了datasource对象后,报如下错误:

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.


解决方案:

在配置文件中的 连接字符串后面加上?serverTimezone=UTC
UTC是统一标准世界时间
 完整的连接字符串示例:jdbc:mysql://localhost:3306/hello?serverTimezone=UTC
如果指定使用gmt+8时区,需要写成GMT%2B8,否则可能报解析为空的错误


参考:https://blog.csdn.net/weixin_42652696/article/details/83864740/
知识需要管理,知识需要分享
游客


返回顶部

公众号

公众号