【问题标题】:Processing 100,000 records update in a jdbc batch在一个 jdbc 批处理中处理 100,000 条记录更新
【发布时间】:2011-02-02 09:49:17
【问题描述】:

我正在使用 jdbc 批处理准备语句在数据库表中插入 132,000 条记录。我面临的问题是所有记录都没有插入到表中,只插入了 1444 条记录。

try{
        StringBuffer insert = new StringBuffer("INSERT INTO mytable (field1,field2,
,field3,field 4 )   VALUES ( ?, ?, ?, ? )");

          pstmt = conn.prepareStatement(insert.toString());
          Iterator cptIcd9Iterator = cptIcd9List.iterator();    
          while(cptIcd9Iterator.hasNext()){
              cptIcd9VO = (CptIcd9VO)cptIcd9Iterator.next();            
              count++;
              pstmt.setString(1, "field1");
              pstmt.setString(2, "field2");
              pstmt.setString(3, "field3");
              pstmt.setInt(4, 4);
              pstmt.addBatch();
          }
           updateCounts = pstmt.executeBatch();
    }
    catch (Exception e) {
        logger.error(e);
   }

谁能帮帮我?

【问题讨论】:

  • 你没有提供足够的信息,例如它会产生错误吗?
  • 不,它不会给出任何错误。它正常退出,没有任何异常或错误
  • updateCounts 最后是什么?这个标志是否只对 1444 行成功?

标签: java jdbc


【解决方案1】:

不能一次性全部插入,必须一步一步来。

阅读this SO post

【讨论】:

    猜你喜欢
    • 2017-01-07
    • 2017-12-01
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    • 2021-09-20
    • 2017-01-11
    • 1970-01-01
    相关资源
    最近更新 更多