[CONJ-433] Clarify the JDBC parameters serverTimezone and useLegacyDatetimeCode with respect to session time zone Created: 2017-02-16 Updated: 2020-06-29 |
|
| Status: | Open |
| Project: | MariaDB Connector/J |
| Component/s: | documentation |
| Affects Version/s: | 1.5.7 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor |
| Reporter: | Lennart Schedin | Assignee: | Diego Dupin |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Windows 10, Server version: 5.5.53-MariaDB mariadb.org binary distribution. java version "1.8.0_45" (Stockholm time zone) |
||
| Description |
Background:I wrote the ticket https://jira.mariadb.org/browse/CONJ-109 a couple of years ago. Back then my opinion was that MariaDB JDBC connector (1.1.7) handled timestamp in a fragile way. More specifically: I had some discussions with developers at MariaDB regarding ticket
as an URL parameter both the JDBC connector and the server both interpret the date String in UTC timezone and the developer does not need take any special time zone care when using ResultSet/ PreparedStatement. Problem:Since that time (version 1.1.7) much has happened in the JDBC connector. In version 1.5.7 my workaround no longer work. The JDBC code that parses/formats timetstamp in both SELECTs and INSERTs have been re-written. More specifically: the JDBC serverTimezone parameter is now effectively ignored in the parsing methods (unless another parameter also is specified). Workaround:By studying the source code I have found a workaround to add to my previous workaround:
By adding useLegacyDatetimeCode=false the JDBC once again respects the serverTimezone parameter. To do for MariaDB:If you don’t want to make any drastic changes to the time zone parsing code or once again change what JDBC parameter that exist I hope that you can perform these tasks:
|
| Comments |
| Comment by Diego Dupin [ 2017-02-21 ] |
|
Hi Lennart Schedin. Date are always a nigthmare in Java, Particulary java.sql.Timestamp that hasn't offset, but in reality is based on java.util.Date that is zoned. I'll try to write it during the week so we can discuss this in detail. |
| Comment by Lennart Schedin [ 2017-02-23 ] |
|
I have tried to search in the MariaDB source code to find a test case that tests exactly what I have missed: a test case that would pass when useLegacyDatetimeCode was set to false, and fail when set to true. I have not found such a case. Therefore I think my test case would contribute to the test base. (Try it, it will fail when changing useLegacyDatetimeCode to true). |
| Comment by Robin Bygrave [ 2020-06-29 ] |
|
Almost every other JDBC driver has no problem with java.sql.Timestamp. MariaDB and MySql both stand out as being "potentially problematic" and the lack of prominent documentation promoting people to use and set useLegacyDatetimeCode=false has the potential to hurt some applications. Especially applications using temporal system versioned tables. > Date are always a nightmare in Java, Particularly java.sql.Timestamp that hasn't offset, but in reality is based on java.util.Date that is zoned. It does not matter if it's offset or zoned as they both effectively get converted to UTC. To me this documentation issue should get a higher priority and some attention. |