Fwd: [threeten-develop] DateTime/Temporal interface and JDBC support

Stephen Colebourne scolebourne at joda.org
Sat Dec 15 14:57:10 PST 2012

FYI, a request from a JSR-310 user.

---------- Forwarded message ----------
From: Meno Hochschild <mhochschild at gmx.de>
Date: 15 December 2012 13:40
Subject: [threeten-develop] DateTime/Temporal interface and JDBC support
To: threeten-develop at lists.sourceforge.net

I wonder if there will be any possibility for JDBC to support more
general temporal types and not only hard-coded choice of 5-6 types
(LocalDate, LocalTime, LocalDateTime, OffsetTime, OffsetDateTime and
maybe Period?). It would be great if JDBC will be able to process
objects of type "Temporal" (now still named DateTime). The background
for this RFE is the freedom to implement other temporal types which are
compatible to those mentioned basic types and can be converted to and
from them.

For example, I plan to implement a date/time-type with full leap second
support. I can easily implement the proposed Temporal-interface and make
it compatible to OffsetDateTime, but to use it in sql/jdbc-context the
user has always to convert manually if JDBC does not define any support
for automatic conversion. And since default interface methods will be
introduced with Java 8, too, it would be relatively easy to embed
conversion code in such a default interface method. The already existing
SQLData-interface is not well-suited because it requires a special
CREATE TYPE-command in the database. For storing a temporal type I
consider a PreparedStatement-method like:

interface SQLType<T> {
     /** Defines the compatible jdbc type as Enum (DATE, TIME, DECIMAL,
VARCHAR etc). */
     JDBCType jdbcType();

     /** Reads/Converts the given SQL value to a user defined type. */
     T readSQL(Object);

     /** Writes/Converts the argument to a basic JDBC type. */
     Object writeSQL(T value);

In java.sql.PreparedStatement:

// uses SQLType#writeSQL in default method and will delegate to old
<T> void setObject(int columnIndex, T value, SQLType<T> type) throws

In java.sql.ResultSet:

// delegates to old getObject()-method and then uses SQLType#readSQL in
default method
<T> T getObject(int columnIndex, SQLType<T> type) throws SQLException;

Please forward this proposal to the JDBC-Group. I understand their
limited time until feature freeze. If not possible then it would be nice
if it is at least available with JDK 9 because it would really be a
powerful feature also well suited for any other types. By the way, I
have seen in OpenJDK-forum for JSR 221 a proposal with similar named
setObject-method, but the proposed signature is very different, much
less powerful (and also I don't see any JavaDoc for their plan) - see

Sorry for my low English but I hope you understand the content of my


LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
threeten-develop mailing list
threeten-develop at lists.sourceforge.net

More information about the jdbc-spec-discuss mailing list