java中的批量导入,批量更新数据
批量插入 数据,提高效率
Dao层
int insertBatch(List<HealthImport> list);
xml文件
<insert id="insertBatch" parameterType="java.util.List" >
insert into health_import
(answer_id, sample_num, `name`,
sex, age, select_goal,
pro_id, pro_name, select_result,
sample, patient_id, barcode,
reviewer, idcard, refer_range,
unit, create_time, `result`,
flag, message)
values
<foreach collection="list" index="index" item="monitor" separator=",">
(#{monitor.answerId,jdbcType=INTEGER}, #{monitor.sampleNum,jdbcType=VARCHAR}, #{monitor.name,jdbcType=VARCHAR},
#{monitor.sex,jdbcType=VARCHAR}, #{monitor.age,jdbcType=VARCHAR}, #{monitor.selectGoal,jdbcType=VARCHAR},
#{monitor.proId,jdbcType=VARCHAR}, #{monitor.proName,jdbcType=VARCHAR}, #{monitor.selectResult,jdbcType=VARCHAR},
#{monitor.sample,jdbcType=VARCHAR}, #{monitor.patientId,jdbcType=VARCHAR}, #{monitor.barcode,jdbcType=VARCHAR},
#{monitor.reviewer,jdbcType=VARCHAR}, #{monitor.idcard,jdbcType=VARCHAR}, #{monitor.referRange,jdbcType=VARCHAR},
#{monitor.unit,jdbcType=VARCHAR}, #{monitor.createTime,jdbcType=TIMESTAMP}, #{monitor.result,jdbcType=INTEGER},
#{monitor.flag,jdbcType=INTEGER}, #{monitor.message,jdbcType=VARCHAR})
</foreach>
</insert>
批量 更新数据 提高效率
Dao层
int updateBatch(List<HealthImport> list);
xml文件
<update id="updateBatch" parameterType="java.util.List" >
<foreach collection="list" item="item" index="index" open="" close="" separator=";">
update health_import
<set>
<if test="item.answerId != null">
answer_id = #{item.answerId,jdbcType=INTEGER},
</if>
<if test="item.sampleNum != null">
sample_num = #{item.sampleNum,jdbcType=VARCHAR},
</if>
<if test="item.name != null">
`name` = #{item.name,jdbcType=VARCHAR},
</if>
<if test="item.sex != null">
sex = #{item.sex,jdbcType=VARCHAR},
</if>
<if test="item.age != null">
age = #{item.age,jdbcType=VARCHAR},
</if>
<if test="item.selectGoal != null">
select_goal = #{item.selectGoal,jdbcType=VARCHAR},
</if>
<if test="item.proId != null">
pro_id = #{item.proId,jdbcType=VARCHAR},
</if>
<if test="item.proName != null">
pro_name = #{item.proName,jdbcType=VARCHAR},
</if>
<if test="item.selectResult != null">
select_result = #{item.selectResult,jdbcType=VARCHAR},
</if>
<if test="item.sample != null">
sample = #{item.sample,jdbcType=VARCHAR},
</if>
<if test="item.patientId != null">
patient_id = #{item.patientId,jdbcType=VARCHAR},
</if>
<if test="item.barcode != null">
barcode = #{item.barcode,jdbcType=VARCHAR},
</if>
<if test="item.reviewer != null">
reviewer = #{item.reviewer,jdbcType=VARCHAR},
</if>
<if test="item.idcard != null">
idCard = #{item.idcard,jdbcType=VARCHAR},
</if>
<if test="item.referRange != null">
refer_range = #{item.referRange,jdbcType=VARCHAR},
</if>
<if test="item.unit != null">
unit = #{item.unit,jdbcType=VARCHAR},
</if>
<if test="item.createTime != null">
create_time = #{item.createTime,jdbcType=TIMESTAMP},
</if>
<if test="item.result != null">
`result` = #{item.result,jdbcType=INTEGER},
</if>
<if test="item.flag != null">
flag = #{item.flag,jdbcType=INTEGER},
</if>
<if test="item.message != null">
message = #{item.message,jdbcType=INTEGER}
</if>
</set>
where pro_id = #{item.proId,jdbcType=VARCHAR} and sample_num = #{item.sampleNum,jdbcType=VARCHAR}
</foreach>
</update>
java中的批量导入,批量更新数据的更多相关文章
- java中,字符串类型的时间数据怎样转换成date类型。
将字符串类型的时间转换成date类型可以使用SimpleDateFormat来转换,具体方法如下:1.定义一个字符串类型的时间:2.创建一个SimpleDateFormat对象并设置格式:3.最后使用 ...
- [diango]批量导入不重复数据
去年研究导入数据的时候写了一个批量导入数据的脚本,但有个问题,如果导入这批数据在数据库中已经存在,那么我们导入的数据不就重复了么,本文就讨论如何解决这个问题? 程序如下: #coding:utf-8 ...
- hibernate批量删除和更新数据
转载自:http://blog.csdn.net/yuhua3272004/article/details/2909538 Hibernate3.0 採用新的基于ANTLR的HQL/SQL查询翻译器, ...
- mybatis 注解的方式批量插入,更新数据
一,当向数据表中插入一条数据时,一般先检查该数据是否已经存在,如果存在更新,不存在则新增 使用关键字 ON DUPLICATE KEY UPDATE zk_device_id为主键 model ...
- sequelize 批量添加和更新数据 bulkCreate
sequelize提供了批量插入数据的方法:Model.bulkCreate([…object]). 例如: let updatePhone = [{userName: '李白‘},{userNam ...
- SQL server 批量插入和更新数据
批量插入数据 insert into A表数据库名.[dbo].A(a,b,c) (select a,b,c from B表数据库名.[dbo].B) 批量更新数据 根据身份证第二位更新性别 upda ...
- java中使用poi导出excel表格数据并且可以手动修改导出路径
在我们开发项目中,很多时候会提出这样的需求:将前端的某某数据以excel表格导出,今天就给大家写一个简单的模板. 这里我们选择使用poi导出excel: 第一步:导入需要的jar包到 lib 文件夹下
- java 中Excel的导入导出
部分转发原作者https://www.cnblogs.com/qdhxhz/p/8137282.html雨点的名字 的内容 java代码中的导入导出 首先在d盘创建一个xlsx文件,然后再进行一系列 ...
- .Net中DataAdapter批量插入和更新数据总结
前言 前段时间一直在忙着项目上线,在做项目的同时遇到了一些之前不曾碰到的问题,因为没有经验,只能从网上找一些相关的解决方案,但是网上提供的资料实在是太杂,有的根本不能用,耗时又耗力. 我希望把我这段时 ...
- java中通过jacob调用dts进行数据导入导出
在一个项目中需要金蝶软件对接,但是业务服务器和财务服务器相隔很远(中间经过好几台服务器,有内网也有外网),从一个内网向另一个内网中传输时,需要外网辅助,因为不让原始数据受污染,使用了DTS数据同步到另 ...
随机推荐
- ElasticSearch、ElasticSearch-head的安装和问题解决
前言:elasticsearch作为一个基于Lucene的分布式搜索引擎,其搜索功能的强大之处不用多说,而elasticsearch-head作为一个node项目,能够轻松管理elasticsearc ...
- (jmeter笔记)有序递增和无序递增
有序递增:计数器 Track counter independently for each user: 不勾选,每个线程引用,顺延递增 勾选 ,每个线程引用,重新计算 Reset counter on ...
- awk 计算
[root@BJ-DATABASES lastday]# ps -aux| grep nginx|grep -v greproot 13783 0.0 0.0 56796 1208 ? Ss 11:1 ...
- Qt 中文编译错误和运行显示乱码
Qt 中文编译错误 Qt error: C2001: 常量中有换行符 解决方法:菜单 --> 编辑 --> 选择编码(select Encoding)--> 文本编码 --> ...
- Apache和Nginx设置伪静态(URL Rewrite)的方法
在Apache中有两种方法配置,一是通过httpd.conf文件,二是通过.htaccess文件. 使用 httpd.conf 来配置 rewrite 策略. 要使用 httpd.conf 文件来设置 ...
- js 俄罗斯方块 canvas
俄罗斯方块背景- canvans 第一次写不知道说些什么好,直接上代码了@_@... jquery引入 <script src="https://cdn.bootcdn.net/aja ...
- nodejs mongoose连接mongodb报错,command find requires authentication
MongoError: command find requires authentication at Connection.<anonymous> (/home/Map/node_mod ...
- Windows 批量测试 ip:port 是否通畅
使用 telnet + cmd 脚本处理: @echo off start cmd /k "telnet 10.2.3.29 3000" start cmd /k "te ...
- day1 AcWing 836. 合并集合
初始化: n个下表对应n个集合,根节点的特征是父节点就是其本身. for(int i = 1; i <= n; i++) p[i] = i; M操作:如果两个元素在同一个集合中,什么也不做,否则 ...
- Linux下添加启动项并简化操作命令-nginx为例
1.添加nginx为启动项 1. vi /etc/rc.d/rc.local 2.将启动命令直接添加到最后即可 *注:通过下图可知 /etc/rc.d/rc.local和 ...