ibatis的批处理
(1)spring模式:尽管spring已经配置了事务,但以下代码中还是要设置事务,不然batch不会起作用;另外这里虽然设了一下事务处理,但对全局事务并不会造成影响;
注:不启用事务将建立多次连接,这表示batch没起作用,建立事务后一次连接就搞定了.
- public void batchAddExamlog(List examlogList) throws SQLException{
- SqlMapClient smc=this.getSqlMapClient();
- try {
- smc.startTransaction();
- smc.startBatch();
- for (Iterator iter = examlogList.iterator(); iter.hasNext();) {
- Examlog log = (Examlog) iter.next();
- smc.update("insertExamlog", log);
- }
- smc.executeBatch();
- } catch (Exception e) {
- // TODO: handle exception
- }finally{
- smc.commitTransaction();
- smc.endTransaction();
- }
- }
(2)直接采用回调函数设置
- public void batchAddExamlog2(List examlogList){
- getSqlMapClientTemplate().execute(new SqlMapClientCallback() {
- public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
- executor.startBatch();
- executor.update("insertSomething", "myParamValue");
- executor.update("insertSomethingElse", "myOtherParamValue");
- executor.executeBatch();
- return null;
- }
- });
- }
ibatis的批处理的更多相关文章
- ibatis实现批处理
最近做一个小项目,用到Spring+iBatis.突然遇到一个很久远,却很实在的问题:在Spring下怎么使用iBatis的批处理实现? 大概是太久没有写Dao了,这部分真的忘得太干净了. 从4个层面 ...
- Ibatis相关
XML中的#和$的区别 http://shenzhenchufa.blog.51cto.com/730213/254561 poolMaximumActiveConnections和poolMaxim ...
- iBatis框架batch处理优化 (转)
为什么要做batch处理 这个问题我就不解释了,因为我想你们肯定能比我解释的更好!如果你真的不知道,那就到Google上去搜索一下吧☻Oracle回滚段 这个问题偶也不很明白,只是 ...
- Spring Batch 批处理框架
<Spring Batch 批处理框架>基本信息作者: 刘相 出版社:电子工业出版社ISBN:9787121252419上架时间:2015-1-24出版日期:2015 年2月开本:16开页 ...
- Ibatis学习总结6--使用 SQL Map API 编程
SQL Map API 力求简洁.它为程序员提供 4 种功能:配置一个 SQL Map,执行 SQL update操作,执行查询语句以取得一个对象,以及执行查询语句以取得一个对象的 List. 配置 ...
- 图书简介:Spring Batch批处理框架
大数据时代批处理利器,国内首度原创解析Spring Batch框架. 内容简介: <Spring Batch 批处理框架>全面.系统地介绍了批处理框架Spring Batch,通过详尽的实 ...
- ibatis框架的sqlmapclient接口
SqlMapClient,是iBatis中的重要接口,这个接口涉及到对SQL映射的执行和批处理. 现在,就先了解它的对query开头方法的定义. 首先是 queryForList 方法: //指定SQ ...
- iBatis系列一
XML iBatis可以使用xml来作为参数输入以及结果返回:这个功能的优势在于某些特定的场景:还有可以通过DOM方式来作为参数传递:但是这个方式应用的比较少,如果服务器是xml服务器可以采用这种方式 ...
- 使用 getNextException() 来检索已经过批处理的特定元素的异常。 ERRORCODE=-4228, SQLSTATE=null
今天查询了一天发现的问题,用ibatis做批量操作时,报错: [非原子批处理出现故障]使用 getNextException() 来检索已经过批处理的特定元素的异常. ERRORCODE=-4228, ...
随机推荐
- LeetCode(1) Symmetric Tree
从简单的道题目開始刷题目: Symmetric Tree 题目:Given a binary tree, check whether it is a mirror of itself (ie, sym ...
- Working with macro signatures
https://docs.kentico.com/k11/macro-expressions/troubleshooting-macros/working-with-macro-signatures ...
- tflearn Training Step每次 We will run it for 10 epochs (the network will see all data 10 times) with a batch size of 16. n_epoch=10, batch_size=16
Training TFLearn provides a model wrapper 'DNN' that can automatically performs a neural network cla ...
- nyoj--744--蚂蚁的难题(一)
蚂蚁的难题(一) 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 小蚂蚁童鞋最近迷上了位运算,他感觉位运算非常神奇.不过他最近遇到了一个难题: 给定一个区间[a,b],在 ...
- 使用filezella服务器安装ftp
使用FileZilla配置FTP站点,可参考以下步骤: 1.打开Filezilla Server服务端: 点击[Edit]->[Users],或者点击如下图标新增用户. 2.添加FTP帐号后,设 ...
- php !=和!==
今天测试了一下!=和!== <?phpheader("Content-type: text/html; charset=utf-8"); if (1!="1&quo ...
- yii1 session
在 Yii框架中使用session 的笔记: 首先,在Yii框架中,你不需要像标准PHP代码那样使用session_start(),在Yii框架中,autoStart 属性缺省被设置为true,所以, ...
- HUdson2092整数解
2019-05-17 16:04:37 加油,坚持就是胜利,fightting m / i的情况,i可能等于0 #include <bits/stdc++.h> using namespa ...
- /etc/rsyslog.conf配置文件说明
一.authpriv.* /var/log/secure 服务名称[连接符号]日志等级 日志记录位 ...
- Fail2ban + firewalld 防护doss攻击
系统环境:centos7.3 用途:利用fail2ban+Firewalld来防CC攻击和SSH爆破 准备工作: 1.检查Firewalld是否启用 #如果您已经安装iptables建议先关闭 ser ...