JdbcTemplate.update核心源码
作者:互联网
protected int update(final PreparedStatementCreator psc, @Nullable final PreparedStatementSetter pss) { return execute(psc, ps -> { pss.setValues(ps); int rows = ps.executeUpdate(); return rows; }); } //---------------------------------------------------------------------------------------------------------------- public <T> T execute(PreparedStatementCreator psc, PreparedStatementCallback<T> action) { Connection con = DataSourceUtils.getConnection(obtainDataSource()); PreparedStatement ps = psc.createPreparedStatement(con); T result = action.doInPreparedStatement(ps); return result; }
模板模式,回调函数,匿名内部类以及lambda的应用
标签:ps,return,int,psc,update,PreparedStatementCreator,源码,JdbcTemplate,result 来源: https://www.cnblogs.com/tsai-87/p/16091166.html