Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 冲浪宝典 > 网络资源 > iBatis对批量update的支持
【标  题】:iBatis对批量update的支持
【关键字】:iBatis,update
【来  源】:http://blog.csdn.net/ngultrum/archive/2006/08/11/1050318.aspx

iBatis对批量update的支持

Your Ad Here

最近遇到需要批量update数据的问题,一开始用了一个for循环去update,数据量大的时候效率很低。原因是for循环每次update一条语句,都是一次连接过程。遇到大批数据更新的时候,效率就可想而知了。在google上找了一遍,发现iBatis里有对批量update的支持,挺好的东西。

代码如下:
    final List tempList = list;
    try {
      if (List tempList != null) {
        template.execute(
            new SqlMapClientCallback() {
          public Object doInSqlMapClient(SqlMapExecutor executor) throws
              SQLException {
            executor.startBatch();
            for (int i = 0, n = tempList.size(); i < n; i++) {
              executor.update("test.batchupdate",(Map)tempList.get(i));
            }
            executor.executeBatch();
            return null;
          }
        }
        );
      }
    }
   用法就是这么简单,但是其工作的原理还没搞懂。

IBM DB2 V9 存储过程异常捕获:【上一篇】
利用复制实现数据同步:【下一篇】
【相关文章】
  • 使用IBatis作数据缓存
  • 解决IBatis中的多对一映射n+1问题
  • Atlas 学习之004:“UpdatePanel ”和“UpdateProgress ”使更新数据呈现动画效果
  • iBatis学习
  • Spring+EasyJWeb+iBatis版j2ee在线购物jpetstore系统源码
  • Atlas学习手记(6):使用Atlas UpdateProgress控件
  • Caused by: java.sql.BatchUpdateException: ORA-0229
  • [转] update-alternatives
  • Spring+EasyJWeb+iBatis版j2ee在线购物jpetstore系统源码发布
  • Atlas学习手记(3):由UpdatePanel开始
  • 【随机文章】
  • 初学Java注意什么?
  • 如何预防青春痘治疗青春痘背上的痘痘如何消除青春痘康本给你健康
  • RH9.0配置路由,透明代理,CS 1.5 服务器,硬盘性能优化!
  • 新浪病毒NMGameX_AutoRun引起全公司所有打印共享器无法使用
  • win32asm,还有谁在用?
  • 学习perl的素材: mysqlhotcopy
  • 在LINUX中用cal命令解了一段人类文明历史
  • Web 控件的使用
  • 深夜有感
  • struts中实现分页
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.