0

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.

2
  • last_edited is a timestamp, it means that you will need to use the timestamp object: new Timestamp(eSheet.getLastEditDate().getTime()) Commented Dec 5, 2014 at 11:13
  • That exception statement basically just says "I got this other exception". Post that one. Commented Dec 5, 2014 at 11:14

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.