jdbcTemplate批量插入、更新

论坛 期权论坛 脚本     
匿名技术用户   2021-1-3 22:08   11   0

jdbcTemplate批量插入、更新

解决方法:

List<Map<String, String>> extList = new ArrayList<Map<String, String>>();

HashMap<String, String> ext = new HashMap<String, String>(){

{

put("key", key);

put("value", value);

}

};

extList.add(ext);

StringBuilder sb = new StringBuilder();

sb.append("insert ignore into tb_call_ext(ext_id,c_id,ext_key,ext_val) values(?,?,?,?) ");

int[] extresult = jdbcTemplate.batchUpdate(sb.toString(), new BatchPreparedStatementSetter() {

@Override

public void setValues(PreparedStatement ps, int i) throws SQLException {

//批量操作代码:http://www.yayihouse.com/yayishuwu/chapter/2085

});

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP