MySQL JDBC Driver 5.1.33 - Time Zone Issue

前端 未结 30 1223
栀梦
栀梦 2020-11-22 05:22

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

相关标签:
30条回答
  • 2020-11-22 06:06

    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!

    0 讨论(0)
  • 2020-11-22 06:07

    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.

    0 讨论(0)
  • 2020-11-22 06:08

    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 &amp; or use a CDATA block.

    0 讨论(0)
  • 2020-11-22 06:08

    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 
    
    0 讨论(0)
  • 2020-11-22 06:08

    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 ]

    0 讨论(0)
  • 2020-11-22 06:08

    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.

    0 讨论(0)
提交回复
热议问题