MySQL JDBC 驱动程序 5.1.33 - 时区问题 [英] MySQL JDBC Driver 5.1.33 - Time Zone Issue

查看:38
本文介绍了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启动app时会抛出这个错误.

I have a Java 1.6 webapp running on Tomcat 7. The database is MySQL 5.5. Previously, I was using Mysql JDBC driver 5.1.23 to connect to the DB. Everything worked. I recently upgraded to Mysql JDBC driver 5.1.33. After the upgrade, Tomcat would throw this error when starting the app.

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.

为什么会这样?

推荐答案

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

Apparently, to get version 5.1.33 of MySQL JDBC driver to work with UTC time zone, one has to specify the serverTimezone explicitly in the connection string.

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

这篇关于MySQL JDBC 驱动程序 5.1.33 - 时区问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆