[CONJ-143] ResultSet.getTime() shouldn't convert TIME fields to the server time-zone Created: 2015-03-02  Updated: 2016-08-24  Resolved: 2016-08-24

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.1.6, 1.1.7, 1.1.8
Fix Version/s: 1.3.0

Type: Bug Priority: Major
Reporter: Sebastian Lövdahl Assignee: Diego Dupin
Resolution: Fixed Votes: 1
Labels: None
Environment:

Ubuntu 14.10, MariaDB 5.5.41-1ubuntu0.14.10.1


Issue Links:
Relates
relates to CONJ-86 getTimestamp use client timezone and ... Closed
relates to CONJ-65 implement serverTimezone JDBC connect... Closed

 Description   

According to the time-zone documentation on https://mariadb.com/kb/en/mariadb/time-zones/ TIME fields should NOT be affected by the server time-zone.

After https://mariadb.atlassian.net/browse/CONJ-65 was solved (from 1.1.6 and onwards, that is) ResultSet.getTime() began converting TIME columns to the server time-zone. This differs from what MySQL Connector/J version 5.1 does at least.



 Comments   
Comment by Sebastian Lövdahl [ 2015-03-02 ]

ResultSet.getDate() could also be affected by this.

Comment by diego dupin (Inactive) [ 2015-05-06 ]

By default, the server time zone is used, and that is normal. The MariaDB connector work accordingly.
(mysql server with the mysql connector work a similar way.)

But your are right, using mysql Connector/J 5.1 work by default only in UTC with MariaDB ,

So depending on your needs :

  • Make the MySQL Connector/J problem to consider the time zone :
    if you really want to use the mysql connector, you have to populate the mysql time zone tables, and set the default time zone in configuration.
    see https://mariadb.com/kb/en/mariadb/mysql_tzinfo_to_sql/ to populate mysql time zone tables if you are on unix.
    and for setting the default time zone, add the default_time_zone parameter in my.conf :
    [mysqld]
    default_time_zone=America/Lima

(and restart MariaDB)

  • you don't want to use server time zone :
    If you want to use one particular date in UTC, you can use the UTC_TIMESTAMP() function, that don't use the server time zone.
    if you want all time datas in UTC change the default 'SYSTEM' time-zone to UTC :
    SET GLOBAL time_zone = '+0:00'; (change time-zone to UTC), and restart MariaDB.
Comment by Sebastian Lövdahl [ 2015-05-07 ]

Sorry, I wasn't clear enough in the original description. What I meant by "This differs from what MySQL Connector/J version 5.1 does at least." was that the described behaviour differs from the mysql connector with mysql server (not mysql connector+mariadb server). I'm not interested in using mysql connector with mariadb server at all. The issue is that the same code behaves differently when mariadb connector+server and mysql connector+server is used.

>> By default, the server time zone is used, and that is normal. The MariaDB connector work accordingly.
>> (mysql server with the mysql connector work a similar way.)

How is that normal? The documentation I linked to clearly states that "Some functions are not affected. These include: UTC_TIMESTAMP() as well as DATETIME, DATE and TIME columns.". When mysql connector+server is used no conversion is done.

Comment by Diego Dupin [ 2016-08-24 ]

Forget to close this issue since it was relative to CONJ-86.
That has been fixed in 1.3.0

Generated at Thu Feb 08 03:13:29 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.