[英]ORA-01843 Not a Valid Month with Oracle SQL
I'm using a sql statement in my program. 我在程序中使用了sql语句。
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 当我执行上述命令时,我得到了此异常,嵌套的异常是java.sql.SQLException:ORA-01843:无效的月份
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: 如果可以使用数据库的日期,请使用
sysdate
即:
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: 或者,您可以将
to_date
添加到查询中:
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'");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.