古詩詞大全網 - 成語查詢 - Java往Oracle中插入timestamp類型數據

Java往Oracle中插入timestamp類型數據

刪掉這行:

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)