Bug #95036 8.0.15 JDBC Driver can not work in DST time zone
Submitted: 16 Apr 2019 7:22 Modified: 29 May 2019 17:20
Reporter: sxq sxq Email Updates:
Status: Duplicate Impact on me:
Category:Connector / J Severity:S1 (Critical)
Version:8.0.15 OS:Linux
Assigned to: CPU Architecture:Any
Tags: jdbc, time zone

[16 Apr 2019 7:22] sxq sxq
when i use mysql-connector-java 8.0.15 with hibernate to connect version 5.5.55 server,i received a exception
java.sql.SQLException: The server time zone value 'CDT' 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)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:89)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:63)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:73)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:76)
	at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:835)
	at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:455)
	at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:240)
	at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:199)
whis happen on when i use day light saving time zone, and when i use mysql-connector-java 5.1.47, it won't happen anymore

How to repeat:
set system time zone in a day light saving time zone,and use version 8.0.15 to connect server

Suggested fix:
when use 5.1.47,it won't happen,so it's a regression
[17 Apr 2019 1:40] sxq sxq
when i add "&serverTimezone=UTC" or "&serverTimezone=CST6CDT" in the connect URL, i can connect to server, but when i use "&serverTimezone=CDT",the exception happen again.i guss the default value of serverTimezone between version 5.1.47 and version 8.0.15 are different, and the new value is not correct.
[21 May 2019 14:29] Alexander Soklakov

This is not a bug.

Exception message contains a hint, "'CDT' ... or represents more than one time zone". You could check, for example, https://www.timeanddate.com/time/zones/ and find:

CDT - Central Daylight Time, North America, UTC -5
CDT - Cuba Daylight Time, Caribbean, UTC -4
CDT - Chatham Daylight Time

The exception usually appears when c/J takes time zone name from operating system which could return one of such ambiguous abbreviations. To fix that you just need to pass the univocal time zone name. In case of Central Daylight Time it would be "&serverTimezone=America/Chicago".
[29 May 2019 17:20] Filipe Silva
This is a duplicate of Bug#85816.

Note that it works when you use "&serverTimezone=UTC" or "&serverTimezone=CST6CDT" because Java recognizes these as valid time zones. "&serverTimezone=CDT" fails because "CDT" is not a valid time zone in Java.

So, this means that you can set whatever time zone values Java recognizes in the connection property "serverTimezone". The options available to you are described in TimeZone Javadoc (https://docs.oracle.com/javase/8/docs/api/index.html?java/util/TimeZone.html). Also mind that, although some are supported, using three-letter time zones is deprecated, as mentioned in the same page.