2

For some reason I am getting this error while trying to start my java app.

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.

I would like to be able to change the timezone on the connection string. So far I tried this:

javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/returnit?useLegacyDatetimeCode=false&serverTimezone=UTC"

and this:

javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/returnit?useLegacyDatetimeCode=false&serverTimezone=Australia/Sydney"

But for some reason mysql is not picking up the timezone and still complains about AEDT?

Mysql connector version is 6.0.6 System I am running in MacOS Mysql version is

QUESTION: Any idea about how to setup serverTimezone through connection string?

thank you very much

masber
  • 2,875
  • 7
  • 29
  • 49
  • There is a similar question asked here : https://stackoverflow.com/questions/930900/how-do-i-set-the-time-zone-of-mysql – sudip Feb 22 '18 at 08:10
  • @sudip yes I want to set the timezone throught the connection string. A potential solution from your link but didn't work – masber Feb 22 '18 at 09:19
  • You want to set the serverTimezone property in mysql server instead of passing timezone as part of connectionString, right? Is the solution https://stackoverflow.com/a/19069310/452213 not working for you? – sudip Feb 22 '18 at 09:25
  • @sudip I want to tell mysql the timezone in the connection string. I preffer not to do that in the database configuration – masber Feb 22 '18 at 12:48
  • `AEDT` is not a time zone id. I'm guessing you want to pass `Australia/Sydney` instead. See [this list](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). – Matt Johnson-Pint Feb 23 '18 at 17:43
  • @MattJohnson thanks, I tried this and unfortunately it didn't work... – masber Feb 24 '18 at 02:54

1 Answers1

4

this is an example of a connection string specifying serverTimezone:

"jdbc:mysql://localhost:3306/returnit?useSSL=false&useUnicode=true&serverTimezone=UTC"
masber
  • 2,875
  • 7
  • 29
  • 49
  • Instead of "returnit" is the name of our project ? It's not working for me and my url is "jdbc:mysql://localhost:3306/PhoneCompany" – Vaggelis Manousakis Jun 15 '20 at 06:45
  • Remove "amp" and ';' characters and change the name to your database's name: jdbc:mysql://localhost:3306/YOUR_DB?useSSL=false&useUnicode=true&serverTimezone=UTC – Kike Lebowski Feb 14 '21 at 16:57