0
votes

While connecting spring boot application to MYSQL database, I got this error:

com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'unknown' 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.

application.properties:

spring.datasource.url=jdbc:mysql://localhost:3306/db
spring.datasource.username=root
spring.datasource.password=
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

If I use serverTimeZone UTC with data source url, then database value sets to 5:30 times back from current local time and also date will be stored as yesterday's date.

spring.datasource.url=jdbc:mysql://localhost:3306/db?serverTimezone=UTC&useLegacyDatetimeCode=false

What should I do to set correct value for date and time?

1

1 Answers

0
votes

?serverTimezone=UTC&useLegacyDatetimeCode=false will work for timezone. I had lots of problems becuase of this little trick even couldnt connect to mysql