简体   繁体   中英

java.sql.SQLException: The server time zone value 'ora legale Europa occidentale' is unrecognized

I have a problem with the connection to database in Spring. My database name is notedb. I use xampp and phpmyadmin for database

This is my application.properties

This is the error

java.sql.SQLException: The server time zone value 'ora legale Europa occidentale' 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.
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:129) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199) ~[mysql-connector-java-8.0.15.jar:8.0.15]`

You can solve the problem by adding the timezone in the URL of the property. This, will force SQL to do not search in the system timezone.

spring.datasource.url=jdbc:mysql://localhost:3306/{your_instance}?serverTimezone=UTC

This issue is specific of Windows and its Italian translation.

How to solve it:

First thing we need to load Time Zones Table as specified at MySQL Server Time Zone Support To do so:

  • download the latest posix zip file: timezone_2019c_posix_sql from: MySQL time table download
  • extract it directly in C:\ for an easy path
  • Launch MySQL Command Line Client
  • execute the following commands from Command Line Client:
    mysql> use mysql;
    mysql> source c:\timezone_posix.sql;
  • execute the following query from Workbench:
    SET GLOBAL time_zone = 'Europe/Rome';

For more information on this issue you could refer to:

https://github.com/TdP-2019/materiale/blob/master/faq/timezone.md (in Italian)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM