Spring JDBC和Oracle DB 12c:java.sql.SQLException:列类型无效.为什么?

Mic*_*zyk 0 java spring spring-jdbc oracle12c spring-boot

我正在努力应对以下异常:

org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [update EVALUATION_SHEET set STATUS=?, LAST_EDITED=? where id=?]; SQL state [99999]; error code [17004]; Invalid column type; nested exception is java.sql.SQLException: Invalid column type
Run Code Online (Sandbox Code Playgroud)

这是扔在这里:

jdbcTemplate.update("update E_SHEET set STATUS=?, LAST_EDITED=? where id=?",
                new Object[]{eSheet.getStatus().ordinal(), eSheet.getLastEditDate(), eSheet.getId()},
                new Object[]{OracleTypes.NUMBER, OracleTypes.TIMESTAMP, OracleTypes.NUMBER});
Run Code Online (Sandbox Code Playgroud)

数据库表创建如下:

create table E_SHEET (
  ID number not null unique,
  ID_POSITION number not null,
  STATUS number default 0 not null,
  ID_EXAMINER number not null,
  LAST_EDITED timestamp not null);
Run Code Online (Sandbox Code Playgroud)

我不知道是什么导致了这个问题.这个方法:

 eSheet.getLastEditDate()
Run Code Online (Sandbox Code Playgroud)

返回java.util.Date对象.我使用Spring JDBC模板和Spring DB以及Oracle DB 12c作为数据源.

小智 6

在春季文档http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jdbc.html之后,更新将如下工作:

jdbcTemplate.update("update t_actor set last_name = ? where id = ?", "Banjo", 5276L);

或者像这样

jdbcTemplate.update("update orders set shipping_charge = shipping_charge * ? / 100 where id = ?", pct, orderId);

但是您将对象数组作为参数传递给方法.

为什么不呢?

jdbcTemplate.update("update E_SHEET set STATUS=?, LAST_EDITED=? where id=?", eSheet.getStatus().ordinal(), eSheet.getLastEditDate(), eSheet.getId());