GetTimestamp () twice converts timezone in MySQL JDBC connector?

I have a column of type DATETIME with a value of 2012-05-07 19:59:12 in a MySQL database. I am trying to extract this value from the database, assuming it is stored in the UTC time zone:

 Calendar cal = Calendar.getInstance(new SimpleTimeZone(0, "UTC")); Date date = resultSet.getTimestamp(1, cal); System.out.println(date); 

It outputs ( CEST is my local time zone, which is 2 hours more than UTC):

 Mon May 07 23:59:12 CEST 2012 

Expected Value:

 Mon May 07 21:59:12 CEST 2012 

I use these three parameters in the JDBC URL ( Europe/Berlin same as CEST ):

 ..&useGmtMillisForDatetimes=true&useTimezone=true&serverTimezone=Europe/Berlin 

Is this my defect, or should something be additionally configured in the JDBC driver? I am using mysql:mysql-connector-java:5.1.20 .

+7
source share
1 answer

Using these JDBC URL parameters, it works:

 useGmtMillisForDatetimes=true useJDBCCompliantTimezoneShift=true useLegacyDate‌timeCode=false useTimezone=true serverTimezone=UTC 
+12
source

All Articles