I have a list of Objects which are set to prepared statement. I have a timestamp value in the list and hence checking the instanceOf
condition and preparedStatement.setTimestamp
to set the value, but it is throwing java.sql.SQLDataException: ORA-01858 a non-numeric character was found where a numeric was expected
. Is the explicit casting a problem ?
My code
int count = 1;
for (int j = 0; j < list.size(); j++) {
logger.info("column: "+count+ " value: "+list.get(j));
if(list.get(j) instanceof Timestamp) {
ps.setTimestamp(count, (Timestamp) list.get(j));
} else {
ps.setObject(count, list.get(j));
}
count++;
}
Prepared Statement
insert into OPRS_ZONES(ZONE_ID,ZONE_CODE,ZONE_NAME,PLACE_ID,CORP_ID,CREATED_BY,CREATED_DATE,MODIFIED_BY,MODIFIED_DATE) values(?,?,?,?,?,?,?,?,?)
Values
column: 1 value: 03.0
column: 2 value: 'HYDERABAD'
column: 3 value: 'HYDERABAD'
column: 4 value: 05231.0
column: 5 value: 01.0
column: 6 value: 01.0
column: 7 value: 2012-10-19 13:06:39.0
column: 8 value: 00.0
column: 9 value: NULL
Tabel structure to which i need to insert the values
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
);
Any inputs are appreciated
Thanks