[CONJ-719] Saving values using Java 8 LocalTime does not store fractional parts of seconds Created: 2019-07-15  Updated: 2019-08-02  Resolved: 2019-07-24

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

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

All



 Description   

When using java.time.LocalTime to store values in DB, org.mariadb.jdbc.BasePrepareStatement loses all the fractional parts of the seconds during the conversion to java.sql.Time and then uses that to store the value. Even if the conversion was done correctly, java.sql.Time only allows storing at millisecond precision, so some data would be lost in any case.

There are proper implementations with correct fractional second support for OffsetDateTime, OffsetTime and ZonedDateTime so I assume this is just an oversight that LocalTime was not supported with fractions support? If it was intentional, then it would still make sense to keep at least millisecond precision which is also supported using the legacy java.sql.Time datatype.

It is possible to work around the issue atm by implementing a custom org.mariadb.jdbc.internal.com.send.parameters.ParameterHolder and using that to set the value using org.mariadb.jdbc.BasePrepareStatement.setParameter()


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