PreparedStatement 中 setDate();怎么用?请前辈指教。

mike_winnor 2002-07-22 09:18:24
我想把当前的日期时间存到oracle,date 类型的字段中。用PreparedStatement的setDate();方法。我该怎么写程序?多谢。
...全文
560 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangwenyou 2002-07-22
  • 打赏
  • 举报
回复
保存日期时间不能用setDate,要用setTimeStamp;如下

pstmt.setTimeStamp(index , new TimeStamp( new Date().getTime() ) );
zwhhwz 2002-07-22
  • 打赏
  • 举报
回复
public void setDate(int parameterIndex,Date x)
Sets the designated parameter to a value. The driver converts this to an SQL DATE value when it sends it to the database.

Parameters:
parameterIndex - the first parameter is 1, the second is 2, ...
x - the parameter value

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧