I'm using a sql statement in my program.
stringBuffer sql=new StringBuffer();
sql.append("insert into customer (id,createddate) ");
sql.append("values (1,");
sql.append("'"+new Timestamp(System.currentTimeMillis())+"'");
String results=jdbcTemplate.update(sql.toString();
when i executed above command,i got this exception nested exception is java.sql.SQLException: ORA-01843: not a valid month
i should bind the current date ,how do i solve this issue.
Thanks.
If you can use the DB's date then use sysdate
ie:
stringBuffer sql=new StringBuffer();
sql.append("insert into customer (id,createddate) ");
sql.append("values (1,sysdate)");
Or you can add a to_date
to the query:
stringBuffer sql=new StringBuffer();
sql.append("insert into customer (id,createddate) ");
sql.append("values (1,to_date(");
sql.append("'"+<your TimeStamp converted to a String like yyyyMMddHHmmss>+"', 'yyyymmddhh24miss'");
Or use a PreparedStatement as here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.