Some background:
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. Ever
I also was having the exact same problem in LibreOffice Base. So I just specified a non 'daylight savings time zone' in the connection string.
I tried without the "&serverTimezone=MST" but that failed as well.
I also tried "&serverTimezone=MDT" and that failed, so for some reason, it doesn't like daylight savings time!
If you are using Maven, you can just set another MySQL connector version (I had the same error, so i changed from 6.0.2 to 5.1.39) in pom.xml
:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.39</version>
</dependency>
As reported in another answers, this issue has been fixed in versions 6.0.3 or above, so you can use the updated version:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.3</version>
</dependency>
Maven will automatically re-build your project after you save the pom.xml
file.
The connection string should be set like this:
jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
If you are defining the connection in an xml
file (such as persistence.xml
, standalone-full.xml
, etc..), instead of &
you should use &
or use a CDATA
block.
I have the same problem and i solved it append only "?serverTimezone=UTC" to my string connection.
#sinossi my problem:
java.sql.SQLException: The server time zone value 'CEST' 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.
my dbDriver = com.mysql.jdbc.Driver
my jar = mysql-connector-java-8.0.12.jar
my java = 1.8
my tomcat = Apache Tomcat Version 8.5.32
my MySql server = MySql ver.8.0.12
i Got error similar to yours but my The server time zone value is 'Afr. centrale Ouest' so i did these steps :
MyError (on IntelliJ IDEA Community Edition):
InvalidConnectionAttributeException: The server time zone value 'Afr. centrale Ouest' 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 u....
I faced this issue when I upgraded my mysql server to SQL Server 8.0 (MYSQL80).
The simplest solution to this problem is just write the below command in your MYSQL Workbench -
SET GLOBAL time_zone = '+1:00'
The value after the time-zone will be equal to GMT+/- Difference in your timezone. The above example is for North Africa(GMT+1:00) / or for India(GMT+5:30). It will solve the issue.
Enter the Following code in your Mysql Workbench and execute quesry
[source link for question/problem ]
[source link for answer]
[Solution ScreenShot ]
I solved this issue without any single code change. just goto system time setting and set the time zone. In my case the default time zone was UTC which I changed to my local time zone. After I did restart all services, everything worked for me.