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

查看:181
本文介绍了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会在启动应用程序时抛出此错误。

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.

为什么会发生这种情况?

Why is this happening?

推荐答案

显然,为了使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天全站免登陆