当我执行我准备好的语句时,我得到了ORA-01858: a non-numeric character was found where a numeric was expected
. 当我搜索一些论坛时,他们说这是因为日期数据类型。我准备好的陈述是
insert into OPRS_ZONES(
ZONE_ID,
ZONE_CODE,
ZONE_NAME,
PLACE_ID,
CORP_ID,
CREATED_BY,
CREATED_DATE,
MODIFIED_BY,
MODIFIED_DATE)
values(?,?,?,?,?,?,?,?,?)
我要插入的值是
03.0,
'FLORIDA',
'FLORIDA',
05231.0,
01.0,
01.0,
TO_DATE('19102012130639','DDMMYYYYHH24MISS'),
NULL,
NULL
表定义
CREATE TABLE OPRS_ZONES (
ZONE_ID NUMERIC(20,0) ,
ZONE_CODE VARCHAR2(16) ,
ZONE_NAME VARCHAR2(255) ,
PLACE_ID NUMERIC(20,0) ,
CORP_ID NUMERIC(20,0) ,
CREATED_BY NUMERIC(20,0) ,
CREATED_DATE DATE ,
MODIFIED_BY NUMERIC(20,0) ,
MODIFIED_DATE DATE );
我为准备好的语句填充值的代码,
public int executePreparedStatement(String query, List myCollection, int colLength, String tableName) throws DBException,SQLException {
int rowsAffected = 0;
int [] noOfRowsExecuted = null;
try{
conn.setAutoCommit(false);
if(query != null){
ps = conn.prepareStatement(query);
for (int i = 0; i < myCollection.size(); i++) {
logger.info("@@mycollcetion -- "+myCollection.get(i));
List list = (List) myCollection.get(i);
int count = 1;
for (int j = 0; j < list.size(); j++) {
ps.setObject(count, list.get(j));
count++;
}
ps.execute();
logger.info("@@ noOfRowsExecuted == "+noOfRowsExecuted);
}
}
}catch(Exception e){
logger.error("Error in the execution of Prepared Statement: \n" + query + "\nData : " + listData, e);
rowsAffected = Utility.getErrorCode(e);
throw new DBException(e);
}finally{
try {
if (ps != null) {
ps.close();
ps = null;
}
} catch (Exception e) {
}
rowsAffected = 0;
noOfRowsExecuted = null;
}
return rowsAffected;
}
list myCollection
包含values
. _ variabelequery
是prepared statement
这个准备好的语句,当用值替换时在 SQLDEVELOPER 中工作正常,但是当我运行我的 java 程序时,我得到了错误。这真的是日期格式的问题吗?如果是这样,为什么它在 SQLDEVELOPER 中运行良好?
请帮忙,
谢谢