データベースに行を追加する 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();
}
}