Home Web Front-end JS Tutorial How SpringJDBC operates data in batches

How SpringJDBC operates data in batches

Apr 16, 2018 pm 01:36 PM
operate data

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!

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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Use ddrescue to recover data on Linux Use ddrescue to recover data on Linux Mar 20, 2024 pm 01:37 PM

Use ddrescue to recover data on Linux

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Apr 03, 2024 pm 12:04 PM

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation!

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Apr 01, 2024 pm 07:46 PM

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Slow Cellular Data Internet Speeds on iPhone: Fixes

The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training Mar 11, 2024 pm 12:10 PM

The first robot to autonomously complete human tasks appears, with five fingers that are flexible and fast, and large models support virtual space training

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times. May 07, 2024 pm 05:00 PM

The U.S. Air Force showcases its first AI fighter jet with high profile! The minister personally conducted the test drive without interfering during the whole process, and 100,000 lines of code were tested for 21 times.

Alibaba 7B multi-modal document understanding large model wins new SOTA Alibaba 7B multi-modal document understanding large model wins new SOTA Apr 02, 2024 am 11:31 AM

Alibaba 7B multi-modal document understanding large model wins new SOTA

See all articles