Michał Kowalczyk
Michał Kowalczyk

Reputation: 478

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.

Upvotes: 0

Views: 11671

Answers (1)

Weggyboy
Weggyboy

Reputation: 106

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

Upvotes: 6

Related Questions