spring2.0.8 批量处理

来源:互联网 发布:哈尔滨 软件开发招聘 编辑:程序博客网 时间:2024/04/28 09:58
 
  1.     public int[] updateKscj(final String[] bmglids,final double[] llbzs,final double[] llzys, final double[] scs){
  2.         
  3.         int[] updateCounts = super.getJdbcTemplate().batchUpdate(
  4.                 "update xj_bmgl set bmgl_llbz = ?, bmgl_llzy = ?,bmgl_llzf=?,bmgl_sc=? where bmgl_id = ?",
  5.                 new BatchPreparedStatementSetter() {
  6.                     public void setValues(PreparedStatement ps, int i) throws SQLException {
  7.                         ps.setDouble(1,llbzs[i] );
  8.                         ps.setDouble(2,llzys[i] );
  9.                         ps.setDouble(3,llbzs[i]+llzys[i] );
  10.                         ps.setDouble(4,scs[i] );
  11.                         ps.setString(5,bmglids[i]);
  12.                     }
  13.                     public int getBatchSize() {
  14.                         return bmglids.length;
  15.                     }
  16.                 } );
  17.         return updateCounts;
  18.         
  19.     }
原创粉丝点击