[CONJ-718] Impossible to use Java 8 OffsetTime datatype Created: 2019-07-15  Updated: 2019-07-15

Status: Open
Project: MariaDB Connector/J
Component/s: JDBC 4.2 compatibility
Affects Version/s: 2.4.2
Fix Version/s: None

Type: Bug Priority: Major
Reporter: Tarmo Randma Assignee: Diego Dupin
Resolution: Unresolved Votes: 0
Labels: None
Environment:

All



 Description   

org.mariadb.jdbc.internal.com.send.parameters.OffsetTimeParameter seems to be broken. It contains the following code:

    ZoneId zoneId = options.useLegacyDatetimeCode ? ZoneOffset.systemDefault() : 
serverZoneId;
    if (zoneId instanceof ZoneOffset) {
      throw new SQLException("cannot set OffsetTime, since server time zone is set to '"
          + serverZoneId.toString() + "' (check server variables time_zone and system_time_zone)");
    }
    this.time = offsetTime.withOffsetSameInstant((ZoneOffset) zoneId);

I am not sure how it is supposed to work but atm it does not seem to be possible to pass in any zoneId that would be accepted. First a validation makes sure that the zoneId is not ZoneOffset and granted that validation is passed, it is then immediately cast to ZoneOffset which fails. So - neither ZoneRegion nor ZoneOffset work here.

org.mariadb.jdbc.internal.com.send.parameters.ZonedDateTimeParameter does not seem to have the validation block, so maybe this is unnecessary also here?

When I implemented my own ParameterHolder and set it on the Statement using setParameter, it was possible to save Java 8 Time types to the DB


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