[CONJ-533] Wrong value when inserting time data type with JDBC java.sql.Time Created: 2017-10-01 Updated: 2017-10-26 Resolved: 2017-10-26 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | 1.6.0, 2.1.2 |
| Fix Version/s: | 2.2.0, 1.7.0 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Max Lam | Assignee: | Diego Dupin |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | JDBC, java.sql.Time | ||
| Environment: |
Mac, Linux, MariaDB 10.2.6, 10.2.7 (Linux Galera) |
||
| Attachments: |
|
| Description |
|
This bug is related to a bug which I've discovered that doesn't happen on MariaDB JDBC Driver Version 1.5.9, but it happened on any version from 1.6.x onwards all the way to ver 2.1.2. The main issue is that whenever a value of 5:00:00 is inserted into the column, and later queried, it will become 19:00:00. To reproduce this issue: create table t_time_test ( 2) I have attached some codes in Java (namely TimeTest.java). This small program inserts a row with the 'time_field' column value of 5AM (doesn't matter about date or time zone), and later query the row inserted. It turns out that on MariaDB JDBC Driver 1.5.9, the time_field column is 05:00:00, but if I were to run this with MariaDB JDBC Driver 1.6.x or 2.1.x, the time_field column is 19:00:00. MariaDB's TimeZone through "SHOW GLOBAL VARIABLES LIKE 'time_zone'" is 'SYSTEM'. Help is much appreciated. |
| Comments |
| Comment by Diego Dupin [ 2017-10-02 ] | ||||||||||||||||
|
I didn't succeed reproducing this issue, and fail to see how that can occur. Could you please indicate :
| ||||||||||||||||
| Comment by Max Lam [ 2017-10-02 ] | ||||||||||||||||
|
The URL/Connection string is as written in the TimeTest.java: The Java default timezone: The result of "SELECT @@time_zone, @@system_time_zone":
------------
------------ Hope these help. | ||||||||||||||||
| Comment by Diego Dupin [ 2017-10-04 ] | ||||||||||||||||
|
Ok, i still see no reason why this could occur. So, if you can run it : This will indicate all needed informations to solve this issue | ||||||||||||||||
| Comment by Max Lam [ 2017-10-04 ] | ||||||||||||||||
|
Thanks for the effort. Did as you've instructed, had an error during mvn exec:java -Dexec.mainClass="Main" So, I'd tried to manually run the codes with SLF4J (binding with jdk logger) on my IDE, the result is as below: | ||||||||||||||||
| Comment by Max Lam [ 2017-10-04 ] | ||||||||||||||||
|
Pardon me, Tried again with my IDE, did get some log now. Here are the results: 1.8.0_121 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: content length=225 conn=1762 com=<hidden> 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762 Data to be inserted: 05:00:00 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) @@time_zone=SYSTEM 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) 2017-10-04 16:38:34 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1762(M) Query result: 19:00:00 | ||||||||||||||||
| Comment by Diego Dupin [ 2017-10-05 ] | ||||||||||||||||
|
Excellent, this has permit to identify the issue. | ||||||||||||||||
| Comment by Diego Dupin [ 2017-10-05 ] | ||||||||||||||||
|
Correction done on 1.6.6-SNAPSHOT and 2.2.0-SNAPSHOT.
| ||||||||||||||||
| Comment by Max Lam [ 2017-10-05 ] | ||||||||||||||||
|
Thanks Diego, the fix is good. Verified. 1.8.0_121 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: content length=234 conn=1792 com=<hidden> 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792 Data to be inserted: 05:00:00 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) @@time_zone=SYSTEM 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.o.StandardPacketOutputStream - send: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) 2017-10-05 21:53:17 [main] TRACE o.m.j.i.i.i.StandardPacketInputStream - read: conn=1792(M) Query result: 05:00:00 |