一些背景:
我在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.
Run Code Online (Sandbox Code Playgroud)
为什么会这样?
跟进https://serverfault.com/questions/191331/should-servers-have-their-timezone-set-to-gmt-utc的问题
MySQL时区应该设置为UTC还是应该设置为与服务器或PHP设置相同的时区?(如果不是UTC)
优缺点都有什么?
MySQL使用时区"GMT + 8"运行,但Tomcat使用"GMT"运行.当我将datetime保存到我的数据库时,一切似乎都没问题,但是当我检查数据库中的datetime值时,我看到了"GMT"值.
此外,当我尝试从数据库中获取值的值时,似乎数据库中的值被视为"GMT + 8",因此Java将值更改为"GMT".
我已经设置了这样的连接URL:
useTimezone=true&serverTimezone=GMT
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
我的问题
MySQL连接器"服务器时区值中欧时间"无法识别或代表多个时区.
该项目
小型Web项目:JavaEE,Tomcat 8.5,MySQL,Maven
我的尝试
context.xml中的连接
URL ="jdbc:mysql://127.0.0.1:3306/rk_tu_lager?useLegacyDatetimeCode = false; serverTimezone = CEST; useSSL = false;
错误:
引起:com.mysql.cj.core.exceptions.InvalidConnectionAttributeException:服务器时区值'Mitteleurop?ische Sommerzeit'无法识别或代表多个时区.如果要使用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值.