MySQL JDBC 驱动程序 5.1.33 - 时区问题

新手上路,请多包涵

一些背景:

我有一个在 Tomcat 7 上运行的 Java 1.6 webapp。数据库是 MySQL 5.5。以前,我使用 Mysql JDBC 驱动程序 5.1.23 连接到数据库。一切正常。我最近升级到 Mysql JDBC 驱动程序 5.1.33。升级后,Tomcat 在启动应用程序时会抛出此错误。

 WARNING: Unexpected exception resolving reference
java.sql.SQLException: The server timezone value 'UTC' is unrecognized or represents
  more than one timezone. You must configure either the server or JDBC driver (via
  the serverTimezone configuration property) to use a more specifc timezone value if
  you want to utilize timezone support.

为什么会这样?

原文由 bluecollarcoder 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 576
2 个回答

显然,要让 5.1.33 版的 MySQL JDBC 驱动程序使用 UTC 时区,必须在连接字符串中明确指定 serverTimezone

 jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

原文由 bluecollarcoder 发布,翻译遵循 CC BY-SA 4.0 许可协议

我已经通过配置 MySQL 解决了这个问题。

SET GLOBAL time_zone = '+3:00';

原文由 Dmitriy Rud 发布,翻译遵循 CC BY-SA 3.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题