I made a java method to add a row to a database. I am calling this method about 1000 plus times for testing purposes. I called the close() method on my prepared statement and i am still getting the oracle error whenever this method is called to insert a row.
Error
ORA-01000: maximum open cursors exceeded
Source Code
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();
}
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…