TheJavaCode.com
http://www.thejavacode.com/

Exception ORA-01000 too many open cursors
http://www.thejavacode.com/viewtopic.php?f=43&t=60
Page 1 of 1

Author:  JavaLover [ Sun Nov 16, 2008 3:36 pm ]
Post subject:  Exception ORA-01000 too many open cursors

Hi Everybody...


While working on an enterprise application I was making a loop to insert records in the database using a PreparedStatement in the beginning I forgot the close the prepared statement each time I finish executing the statement and I was inserting the records in a while loop which goes on for like 1000 records.

When trying this I got the exception Exception ORA-01000 too many open cursors
When searching for the cause of the problem I found that oracle creates a new cursor object in the DBMS and because I was not closing prepared statements the cursors was all the time there and they were increasing until they exceed the number defined in the oracle parameter OPEN_CURSORS

I used the following to get the number of open cursors

Code:
SELECT v.value as numopencursors ,s.machine ,s.osuser,s.username
FROM V$SESSTAT v, V$SESSION s
WHERE v.statistic# = 3 and v.sid = s.sid


Finally I solved the problem by creating few prepared statements and just changing the parameters every time I'm gonna execute (which is why there are prepared statements from the first place)
:D

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/