![](/img/trans.png)
[英]java.sql.SQLException:Could not rollback with auto commit set on (JDBC with OracleConnection ,Weblogic 12c)
[英]Spring JDBC & Oracle DB 12c: java.sql.SQLException: Invalid column type. Why?
我正在努力解决以下异常:
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
在这里抛出:
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});
数据库表的创建如下:
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);
我不知道是什么引起了问题。 该方法:
eSheet.getLastEditDate()
返回java.util.Date对象。 我正在将Spring JDBC模板与Spring Boot和Oracle DB 12c用作数据源。
在Spring文档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());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.