到目前为止我试过
jdbcTemplate.update("INSERT INTO INFO (id, my_date)
"VALUES(?, ?)", 1, "sysdate");
还通过仅使用地图尝试使用 namedParameterJdbcTemplate。
Map namedParameters = new HashMap();
namedParameters.put("id", 1);
namedParameters.put("my_date", "sysdate");
namedParameterJdbcTemplate.update("INSERT INTO INFO (id, my_date)
"VALUES(:id, :my_date)",namedParameters);
在尝试了以上所有之后,异常如下
org.springframework.dao.DataIntegrityViolationException: PreparedStatementCallback; SQL [INSERT INTO INFO (id, my_date)
"VALUES(?, ?)]; ORA-01858: a non-numeric character was found where a numeric was expected
; nested exception is java.sql.SQLDataException: ORA-01858: a non-numeric character was found where a numeric was expected
at org.springframework.jdbc.support.SQLExceptionSubclassTranslator.doTranslate(SQLExceptionSubclassTranslator.java:82) ~[spring-jdbc-4.3.17.RELEASE.jar:4.3.17.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:73) ~[spring-jdbc-4.3.17.RELEASE.jar:4.3.17.RELEASE]
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:82) ~[spring-jdbc-4.3.17.RELEASE.jar:4.3.17.RELEASE]
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:655) ~[spring-jdbc-4.3.17.RELEASE.jar:4.3.17.RELEASE]
找到了这个链接,他们声称是可能的。我不明白怎么做,除非我做错了什么。有什么建议吗? http://forum.spring.io/forum/spring-projects/data/99020-is-it-possible-to-use-oracle-s-sysdate-with-simplejdbcinsert