jcabi / jcabi-jdbc

Fluent Object-Oriented Wrapper of JDBC
https://jdbc.jcabi.com/
Other
104 stars 30 forks source link

Utc class should be removed #78

Open Glusk opened 4 years ago

Glusk commented 4 years ago

Utc should be removed from source.

According to this SO answer, SQL timestamps should be set and queried via the Instant class:

If you were using java.sql.Timestamp to exchange data with a database, no need for that class anymore. As of JDBC 4.2 and later, you can directly exchange java.time objects with your database.

myPreparedStatement.setObject( … , instant ) ;

...and…

Instant instant = myResultSet.getObject( … , Instant.class ) ;

It should be documented in the README.md that one should work with Instant objects whenever trying to set or query a java.sql.Timestamp.

0crat commented 4 years ago

@yegor256/z please, pay attention to this issue

0crat commented 4 years ago

@glusk2/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!

andreoss commented 3 years ago

@yegor256 What do you think? With better JSR310 support, Utc wouldn't be necessary .

yegor256 commented 3 years ago

@Glusk @andreoss I agree. But we will have to release a new major version of jcab-jdbc, I believe.

andreoss commented 3 years ago

@Glusk After looking into the details it appears that 1) The current version of pgjdbc does not support Instant https://github.com/pgjdbc/pgjdbc/issues/1325 2) H2 does support Instant but only in the latest version 3) MaridDB/MySQL Connector does not support Instant

Glusk commented 3 years ago

@andreoss

Looking at this page, JDBC 4.2 spec seems to be supported by the most up to date Connector/J version.

This SO answer claims that there is support for Instant in pgjdbc

On the other hand I've also come across this:

FYI, Instant is not supported by JDBC at all. From this comment

I clearly don't know enough about this.