【发布时间】:2021-03-23 21:46:52
【问题描述】:
我正在使用HSQLDB 2.4.0、jOOQ 3.7.1、Scala 2.11.7、Java 8。
我正在尝试将java.time.OffsetDateTime 插入HSQLDB 表中的TIMESTAMP WITH TIME ZONE 列:
sql.insertInto(MY_TABLE)
.columns(MY_TABLE.INSERTED_ON)
.values(java.time.OffsetDateTime.now())
.execute()
我收到以下异常:
org.hsqldb.HsqlException: data exception: invalid datetime format
我做错了什么?
【问题讨论】:
-
有趣!我在这里没有发现任何问题。从
HSQLDB 2.4.0开始支持TIMESTAMP WITH TIME ZONE,对应的Java 类型确实是java.time.OffsetDateTime。但是,我不知道jOOQ。我也想知道这个问题怎么会是近距离投票和否决票。 -
我已经验证如果我将列类型更改为
varchar... -
应该是找到原因了。检查github.com/jOOQ/jOOQ/issues/9174,上面写着:
For backwards compatibility reasons, we're still binding JSR 310 types as strings in most dialects, as JDBC drivers haven't adopted them immediately. There's a pending feature request to pass the JSR 310 type instead of the string:#9902 -
我不确定他们建议做什么。我必须升级到 jOOQ 3.14 吗?
-
恕我直言,升级到最新版本的
jOOQ是最好的选择。
标签: java scala datetime hsqldb jooq