在jdbc批处理中处理100,000条记录更新
问题描述:
我使用jdbc批处理语句在数据库表中插入132,000条记录。我面临的问题是所有记录都没有插入到表中,只插入记录1444。在jdbc批处理中处理100,000条记录更新
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);
}
任何人都可以帮我吗?
你没有提供足够的信息,例如它是否会产生错误? – Matt 2011-02-02 10:32:09