因为你的前rs,已经占用了连接,如果你的连接池中的连接数少于你的rs的记录数,会出现死机的。
可以这样解决,在while循环中你在建立一个conn连接,然后处理executeUpdate,记住这个连接一处理完这个executeUPdate后,一定要立马释放掉:
while(rs.close())
{
try
{
conn=ds.getConnection();
stmt=conn.createStatment();
stmt.executeUpdate();
}
catch(IOExcetpion e)
{
}
finally
{
if(stmt!=null)
stmt.close();
if(conn!=null)
conn.close();
}
}
可以这样解决,在while循环中你在建立一个conn连接,然后处理executeUpdate,记住这个连接一处理完这个executeUPdate后,一定要立马释放掉:
while(rs.close())
{
try
{
conn=ds.getConnection();
stmt=conn.createStatment();
stmt.executeUpdate();
}
catch(IOExcetpion e)
{
}
finally
{
if(stmt!=null)
stmt.close();
if(conn!=null)
conn.close();
}
}
while(){stmt.addBatch(sql);
}
int [] updateCounts = stmt.executeBatch();
conn.commit();
conn.setAutoCommit(true);//可选