【解决方案】springJDBC 出现 bug 的场景

Viewed 63

springJDBC 出现 bug 的场景:
先执行 update 语句:
jdbcTemplate.execute(sql); // 这个 sql 是 update .... 语句
然后再执行 select .... 语句
jdbcTemplate.queryForList(sql);

就会报错:
org.springframework.dao.TransientDataAccessResourceException: StatementCallback; SQL [select xxxxxxx]; ResultSet is from UPDATE. No Data.; nested exception is java.sql.SQLException: ResultSet is from UPDATE. No Data.

这个场景同样在mysql测试过,可以正常执行。

解决方案:

jdbcTemplate.batchUpdate(数组) 来执行 update 语句,然后再执行 select 语句就不会报错。

1 Answers

感谢反馈分享;解决方案:
jdbcTemplate.batchUpdate(数组) 来执行 update 语句,然后再执行 select 语句就不会报错。