Java MySQL 连接器错误“服务器时区值中欧时间”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50493398/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
MySQL connector error "The server time zone value Central European Time"
提问by Martin Klestil
My problem
我的问题
MySQL connector "The server time zone value Central European Time" is unrecognized or represents more than one time zone.
MySQL 连接器“服务器时区值中欧时间”无法识别或代表多个时区。
The project
该项目
Small web Project with: JavaEE, Tomcat 8.5, MySQL, Maven
小型网络项目:JavaEE、Tomcat 8.5、MySQL、Maven
My attempt
我的尝试
- Maven -> change MySQL-connector form 6.x to 5.1.39 (no change)
- Edit context.xml URL change
- Maven -> 将 MySQL-connector 表单 6.x 更改为 5.1.39(无更改)
- 编辑 context.xml URL 更改
Connection in context.xml
context.xml 中的连接
URL="jdbc: mysql://127.0.0.1:3306/rk_tu_lager?useLegacyDatetimeCode=false;serverTimezone=CEST;useSSL=false;
URL="jdbc: mysql://127.0.0.1:3306/rk_tu_lager? useLegacyDatetimeCode=false;serverTimezone=CEST;useSSL=false;
Error:
错误:
Caused by: com.mysql.cj.core.exceptions.InvalidConnectionAttributeException: The server time zone value 'Mitteleurop?ische Sommerzeit' 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.
引起:com.mysql.cj.core.exceptions.InvalidConnectionAttributeException:服务器时区值“Mitteleurop?ische Sommerzeit”无法识别或代表多个时区。如果您想利用时区支持,您必须将服务器或 JDBC 驱动程序(通过 serverTimezone 配置属性)配置为使用更具体的时区值。
采纳答案by Martin Klestil
Thank you Mark Rotteveel and Gord Thompson
谢谢 Mark Rotteveel 和 Gord Thompson
I have the connection in an XML file, with &
and Europe/Amsterdam
finally works.
我在一个 XML 文件中建立了连接&
,Europe/Amsterdam
最终可以工作。
url="jdbc:mysql://127.0.0.1:3306/rk_tu_lager?useLegacyDatetimeCode=false&serverTimezone=Europe/Amsterdam&useSSL=false"
Thank you, you are great
谢谢你,你很棒
回答by corey
If you are using MySQL client eg. DBeaver you should change settings of your connection. So, click right click mouse on the connection and click Edit Connection. Then, edit your driver properties which are located under the "Connection settings", go to the bottom of settings and click "Add new property", add serverTimezone as your new property name and enter value eg. Europe/Warsaw. That's all.
如果您使用的是 MySQL 客户端,例如。DBeaver 你应该改变你的连接设置。因此,在连接上单击鼠标右键,然后单击“编辑连接”。然后,编辑位于“连接设置”下的驱动程序属性,转到设置底部并单击“添加新属性”,将 serverTimezone 添加为新属性名称并输入值,例如。欧洲/华沙。就这样。
回答by vikash singh
I faced this issue when I upgraded my mysql server to SQL Server 8.0 (MYSQL80).
当我将 mysql 服务器升级到 SQL Server 8.0 (MYSQL80) 时,我遇到了这个问题。
The simplest solution to this problem is just write the below command in your MYSQL Workbench -
解决这个问题最简单的方法就是在你的 MYSQL Workbench 中编写以下命令 -
SET GLOBAL time_zone = '+5:30'
The value after the time-zone will be equal to GMT+/- Difference in your timezone. The above example is for India(GMT+5:30). It will solve the issue.
时区之后的值将等于 GMT +/- 您所在时区的差异。上面的例子适用于印度(GMT+5:30)。它将解决问题。
回答by JasonLi
Find what is the timezone you are in and replace +00:00 with your timezone.
找出您所在的时区并将 +00:00 替换为您的时区。
SET @@global.time_zone = '+00:00'; SET @@session.time_zone = '+00:00';
SET @@global.time_zone = '+00:00'; SET @@session.time_zone = '+00:00';
Then check if the values were set:
然后检查是否设置了值:
SELECT @@global.time_zone, @@session.time_zone; enter image description here
选择@@global.time_zone,@@session.time_zone; 在此处输入图片说明