简体   繁体   中英

Spring JDBC & Oracle DB 12c: java.sql.SQLException: Invalid column type. Why?

I'm struggling with following exception:

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

Which is thrown here:

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});

The database table is created as follows:

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);

I have no idea what is causing the problem. This method:

 eSheet.getLastEditDate()

returns java.util.Date object. I am using Spring JDBC template with Spring Boot and Oracle DB 12c as a datasource.

after the spring documentation http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jdbc.html , an update would work like this:

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

or like this

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

But you are passing arrays of Objects as parameters to the method.

Why not just this?

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

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM