When I set useLegacyDatetimeCode=false in my JDBC connection properties, I get this error message:
java.sql.SQLException: The server timezone value 'CET' represents more than one timezone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc timezone value if you want to utilize timezone support. The timezones that 'CET' maps to are: Europe/Tirane, Europe/Andorra, Europe/Vienna, Europe/Minsk, Europe/Brussels, Europe/Sofia, Europe/Prague, Europe/Copenhagen, Europe/Tallinn, Europe/Berlin, Europe/Gibraltar, Europe/Athens, Europe/Budapest, Europe/Rome, Europe/Riga, Europe/Vaduz, Europe/Vilnius, Europe/Luxembourg, Europe/Malta, Europe/Chisinau, Europe/Tiraspol, Europe/Monaco, Europe/Amsterdam, Europe/Oslo, Europe/Warsaw, Europe/Lisbon, Europe/Kaliningrad, Europe/Madrid, Europe/Stockholm, Europe/Zurich, Europe/Kiev, Europe/Uzhgorod, Europe/Zaporozhye, Europe/Simferopol, Europe/Belgrade, Africa/Algiers, Africa/Tripoli, Africa/Casablanca, Africa/Tunis, Africa/Ceuta.
I understand what the message is telling me, but I'm not sure what to do about it. I don't have any way of knowing what time zone the MySQL server is running in (this is software that my customers install, and the servers are not managed by me).
I need to set this property to false to fix MySQL time zone bugs.
To explicitly specify the system time zone for MySQL Server at startup, set the TZ environment variable before you start mysqld. If you start the server using mysqld_safe, its --timezone option provides another way to set the system time zone. The permissible values for TZ and --timezone are system dependent.
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).
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.
URL for Connection:- The connection URL for the mysql database is jdbc:mysql://localhost:3306/mydb ('mydb' is the name of database).
You need to pass an additional parameter like this:
db=jdbc:mysql://localhost/db?user=me&pass=secret&useLegacyDatetimeCode=false&serverTimezone=Europe/Vienna
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