nutzam / nutz

Nutz -- Web Framework(Mvc/Ioc/Aop/Dao/Json) for ALL Java developer
https://nutzam.com
Apache License 2.0
2.53k stars 942 forks source link

批量插入 Oracle 中日期处理的问题 #612

Closed hiscaler closed 10 years ago

hiscaler commented 10 years ago

batchInsert.params().set("CREATETIME", DateTimeHelper.toOracleDate(createTime))

批量插入数据,set 方法中在 oracle 中日期是需要 to_date 才能插入的,nutz 会自动加上引号,变成'to_date(''2013-11-13 18:25:52'', ''yyyy-MM-dd HH24:mi:ss'')',程序出错

zozoh commented 10 years ago

toOracleDate 返回啥类型的对象?

hiscaler commented 10 years ago

一个字符串 to_date(''2013-11-13 18:25:52'', ''yyyy-MM-dd HH24:mi:ss'')

zozoh commented 10 years ago

你换成 batchInsert.vars().set("CREATETIME", DateTimeHelper.toOracleDate(createTime)) 你原来 SQL 里写 @CREATETIME 的改成 $CREATETIME

zozoh commented 10 years ago

实际上,我认为你的 DateTimeHelper.toOracleDate(createTime) 应该返回一个 Timestamp 对象,或者 Date 对象,这样在 Oralce 的 JDBC 驱动里,应该会转换成自己需要的时间对象的 对于批量插入数据,这应该是唯一的方法

hiscaler commented 10 years ago

嗯,我试试,多谢。

zozoh commented 10 years ago

如果搞定了,你就关了这个 issue 吧

hiscaler commented 10 years ago

使用 Date 传入就可以了。多谢。