我正在使用PreparedStatement从 Java 向 Oracle 中插入数据。
以下是我的查询:
String query ="insert into table_name(ID, Date) values(?,(select to_char(TO_TIMESTAMP_TZ(REPLACE('Wed May 29 09:26:59 IST 2013','IST','Asia/Calcutta'),'Dy Mon DD hh24:mi:ss TZR YYYY'),'Dy Mon DD hh24:mi:ss YYYY') from dual))";
pstmt = con.prepareStatement(query,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
pstmt.setString(1, ID);
pstmt.setString(2, "Fri Aug 02 12:38:35 IST 2013");
pstmt.executeUpdate();
但我得到了例外:
java.sql.SQLException: ORA-01858: a non-numeric character was found where a numeric was expected
因此,任何建议将不胜感激。
更新1
我尝试设置时间戳:
pstmt.setTimestamp(1,Timestamp.valueOf("Fri Aug 02 12:38:35 IST 2013"));
但后来我得到了例外:
java.lang.IllegalArgumentException: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff]