批量插入数据
内存溢出Iterator iterator=s.iterator();
while(iterator.hasNext())
{
//System.out.println(iterator.next());
ps.setObject(1, iterator.next());
ps.setString(2, "0 ");
ps.addBatch();
}
ps.executeBatch();
如果用插入5万的可以,但是如果50万就溢出
------解决方案--------------------无语,你不会判断一下啊,每一100条就马上更新啊.
Iterator iterator=s.iterator();
int i=1;
while(iterator.hasNext())
{
//System.out.println(iterator.next());
ps.setObject(1, iterator.next());
ps.setString(2, "0 ");
ps.addBatch();
i++;
if(i%100==0)
{
ps.executeBatch();
}
}
ps.executeBatch();