Home > Web Front-end > JS Tutorial > body text

How SpringJDBC operates data in batches

php中世界最好的语言
Release: 2018-04-16 13:36:11
Original
1290 people have browsed it

This time I bring to you, what are the precautions, the following is a practical case, let's take a look.

Parameters:

List<Map> paramMaps = new ArrayList<Map>();
for(int i = 0; i < 100; i++ ){
    Map paramMap = new HashMap();
    paramMap.put("param1", "param1");
    paramMap.put("param2", "param2");
    paramMap.put("param3", "param3");
    paramMap.put("param4", "param4");
    paramMap.put("param5", "param5");
    paramMaps.add(paramMap);
}
Map[] paramMap = paramMaps.toArray(new HashMap[paramMaps.size()]);
Copy after login

Method:

public void saveSpringJDBC(Map[] paramMap) throws Exception {
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
    StringBuffer sql = new StringBuffer();
    sql.append("Insert into 表名 ");
    sql.append("  (param1, param2, param3, param4) ");
    sql.append(" Values ");
    sql.append("  (:param1, :param2, :param3, :param4 ");
    namedParameterJdbcTemplate.batchUpdate(sql.toString(), paramMap);
}
public void ticketIssueCusInfo(Map[] paramMap) throws Exception{
    NamedParameterJdbcTemplate namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(jdbcTemplate);
    StringBuffer sql = new StringBuffer();
    sql.append(" UPDATE 表名 ");
    sql.append(" SET param1= :param1, param2 = :param2 ");
    sql.append(" WHERE param3 = :param3");
    namedParameterJdbcTemplate.batchUpdate(sql.toString(), paramMap);
}
Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

el-uploadHow to upload an Excel file

Dynamicly obtain the bytes and characters of the current input content number

The above is the detailed content of How SpringJDBC operates data in batches. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!