DB:
$ mysql --version mysql Ver 14.14 Distrib 5.6.27, for osx10.10 (x86_64) using EditLine wrapper
Spring Boot: 2.1.1.RELEASE
The error:
2019-01-01 15:56:25.849 ERROR 39957 --- [ restartedMain] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Exception during pool initialization. > :bootRun java.sql.SQLException: The server time zone value 'AEDT' 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.
Relevant parts of my properties file:
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/avmaint-local?useSSL=false&serverTimezone=UTC spring.datasource.username=##### spring.datasource.password=######## spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
What I find odd about this is that the error indicates that the timezone being used it AEDT, and yet I specified UTC in the spring.datasource.url
. Does Hikari read something else when it initializes?
It does look very much like Hikari ignores the server timezone setting in the database url in favour of using my own machine's timezone which happens to be 'AEDT' (Melbourne, Australia) - This is unwanted behaviour. I would like Hikari to ignore my own machine's timezone. Does anyone know how to make it do that?
To set the timezone for a given JDBC connection, navigate to the Advanced tab and select the timezone from the dropdown menu. By default, UTC is selected.
Option 2: Edit the MySQL Configuration File Scroll down to the [mysqld] section, and find the default-time-zone = "+00:00" line. Change the +00:00 value to the GMT value for the time zone you want. Save the file and exit. In the example below we set the MySQL Server time zone to +08:00 (GMT +8).
While run any application in JVM, JVM will take system default time zone. For example production server is running under PST timezone and spring boot application will start then application will take PST timezone by default.
You can explicitly set a default time zone on the command line by using the Java system property called user. timezone . This bypasses the settings in the Windows operating system and can be a workaround.
Set useLegacyDatetimeCode
false and set ServerTimezone.
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/avmaint-local?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With