在java 中用TimeStamp怎么接收oracle中的Date数据

2024-11-09 04:24:39
推荐回答(2个)
回答1:

删掉这行:
Timestamp stamp = DateConventer.strWithtimeToTimestamp("2009-02-07 12:10:30");
改成
String stamp = "2009-02-07 12:10:30";

然后把:
String executeSql = "insert into TB_Tickets (TicketID,TicketName," +
"StadiumID,Price,Descn,BeginTime) values("+"seq_mp.nextval"+",?,?,?,?,"
+stamp+")";
改成:
String executeSql = "insert into TB_Tickets (TicketID,TicketName,"
+ "StadiumID,Price,Descn,BeginTime) values(" + "seq_mp.nextval"
+ ",?,?,?,?,to_date('" + stamp + "','yyyy-mm-dd hh24:mi:ss'))";
就可以了,试试看

按照你补充为题所说的,那你就需要使用PreparedStatement进行数据加载:
imestamp stamp = DateConventer.strWithtimeToTimestamp("2009-02-07 12:10:30");
String executeSql =".....";
PreparedStatement.setTimestamp(parameterIndex,Timestamp)

回答2:

使用java.util.Date类