Template中execute和update的区别

1、update可以带参数,而execute不可以。例如:
jdbcTemplate.update(“update TableA set name = 'Andy’ where id=?”, new Object[] {new Integer(3)});
jdbcTemplate.execute(“update TableA set name = 'Andy’ where id=3”);
2、update背后是借助于Java.sql.PreparedStatement完成,而execute是基于java.sql.Statement。
3、update返回int, 即受影响的行数。execute返回void

4、execute不接受参数,无返回值,适用于create和drop table。
update可以接受参数,返回值为此次操作影响的记录数,适合于insert, update, 和delete等操作。

转载于:https://hq82001.iteye.com/blog/2294911

posted @ 2019-08-13 12:08  Bean冷的心  阅读(736)  评论(0编辑  收藏  举报