Bug #109929 | after 8.0.23 upgrade, server time is not converting to JVM timezone | ||
---|---|---|---|
Submitted: | 3 Feb 21:39 | Modified: | 16 Mar 4:54 |
Reporter: | Rajesh Kumar | Email Updates: | |
Status: | Analyzing | Impact on me: | |
Category: | Connector / J | Severity: | S2 (Serious) |
Version: | OS: | Any | |
Assigned to: | MySQL Verification Team | CPU Architecture: | Any |
[3 Feb 21:39]
Rajesh Kumar
[21 Feb 12:52]
MySQL Verification Team
Hello Rajesh Kumar, Thank you for the bug report. Could you please provide below info? 1. Exactly what database types are you talking about? 2. What's your server configured time zone? 3. What's your client/JVM time zone? 4. An example of a value as seen via mysql client running in the server (it's important to run the mysql client in the same machine as the server) 5. How the same value is being returned to the client? 6. A simple java test code that returns such value And, obviously, the specific connection setting you're testing with regard to connectionTimeZone, forceConnectionTimeZoneToSession and preserveInstants configurations. Please do not use any third party component/framework when doing the simple test case. Just plain Java and MySQL Connector/J. Regards, Ashwini Patil
[15 Mar 23:59]
Rajesh Kumar
Hi Ashwini, Here are my answers. 1) We are connecting to MySQL database. 2) Database timezone is PST 3) JVM timezone is UTC 4) Yes when we see value of time on server it is same as database. 5) The value of datetime field in database is "2023-02-27T00:21:35". When we are using 8.0.17 connector we are getting the converted value "2023-02-27T08:21:35". You can see 8 added to hours and when we are using 8.0.23 connector or above version we are getting the same value without time zone conversion "2023-02-27T00:21:35. We are passing the connection values(preserveInstants=true&forceConnectionTimeZoneToSession=false) in connection also as suggested in documentation to get the converted value. "jdbc:mysql://localhost:3306/db1?connectionTimeZone=SERVER&preserveInstants=true&forceConnectionTimeZoneToSession=false" 6) Here is the java code. import java.sql.*; class MySQLTest{ public static void main(String args[]) { new MySQLTest().MySQLDatabase_Date_Test(); } public void MySQLDatabase_Date_Test(){ { System.out.println("------Start MySQLTest Test------"); Connection con= null; ResultSet rs= null; try{ //Class.forName("com.mysql.jdbc.Driver"); con= DriverManager.getConnection( "jdbc:mysql://localhost:3306/db1?connectionTimeZone=SERVER&preserveInstants=true&forceConnectionTimeZoneToSession=false","root","******"); Statement stmt=con.createStatement(); rs=stmt.executeQuery("SELECT * FROM Fruit"); while(rs.next()){ System.out.println("Date : " + rs.getObject(2)); } System.out.println(); }catch(Exception e){ System.out.println(e); } finally { try { if(con !=null) { con.close(); } if(rs !=null) { rs.close(); } } catch (SQLException e) { e.printStackTrace(); } } System.gc(); } }