ResultSet wihtin ResultSet but causes cursor problem?

10-11  Source: Network gathering  Views:0 

I have a SQL error when running the code below:
while({ ...
String s= rs0.getString(1);
ResultSet rs=null;
rs=getResult1(aConnnection, s);
/*statment is created in the function and ResultSet returned */
while({ ...
Error: java.sql.SQLException: ORA-01000: maximum open cursors exceeded
The database setting is 200 cursors
and rs0 has 300 records, rs has only one record each time. I thought there should be only 2 cursors involved, do not know how can get so many.
Could some one help with my question?
Thanks in advance,
Rethink your design.
If you let a method create a statement and a resultset, but return only the resultset, then there's no possibility to close the statetement.
I would create the statement outside the method, pass it to the method to do the query and return the resultset, but control the statement in my calling code.
So in your example you would hold references to 2 stattement just the same way like to their resultsets and close them all together.
This is more clean, and maybe will solve your cursor problem.
If you should come to the result that you would really need more open cursors (if your app runs on many clients at the same time, it could), there must be a DBMS configuration for increasing this limit.
Related articles