我做了一个java方法来向数据库添加一行。出于测试目的,我调用此方法大约 1000 多次。我在准备好的语句上调用了 close() 方法,但每当调用此方法插入行时,我仍然会收到 oracle 错误。
错误
ORA-01000: maximum open cursors exceeded
源代码
public void insertARow(ArrayList<String> row)
{
try
{
//Proper SQL statement here, checked by running on DB
String insert = "INSERT INTO user.info(cola,colb) values(?,?)";
//Add a row
PreparedStatement ps = con.prepareStatement(insert);//con is a connection object
//'row' is an arraylist of strings
for(int i = 0; i < row.size(); i++ )
{
int j = 1 + i ;
String temp = row.get(i);
ps.setString(j , temp);
}
ps.executeUpdate();//The reason for problems !!!
ps.close();
}catch(SQLException e)
{
System.out.println("Cannot add row !");
e.printStackTrace();
}
}