Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Open Cursors in Java
Are you sure you've closed all ResultSets and Statements in a
**finally** clause, as should be done with any type of resource release
in Java. Otherwise, you might leak resources when an uncaught exception
occurs.
Try something like:
ResultSet rs = null;
PreparedStatement ps = null;
try
{
...
}
catch(...)
{
...
}
finally
{
if (rs != null)
{
try { rs.close(); } catch (Exception e) { }
}
if (ps != null)
{
try { ps.close(); } catch (Exception e) { }
}
}
Cheers,
Dave
Carlos wrote:
> Hi everybody.
>
> I have a problem with open cursors in Java. I'm connecting to Oracle
> with a jdbc driver and I've found the
> next error: "Max Open Cursors Exceeded".
> I've read many messages about this issue but this error follows me.
>
> In some messages people tell that you have to close the ResultSet and
> the Statement. I've done it.
>
> Other messages talk about loops and that you have to close the
> ResultSet in each iteratio of the loop. I've done it.
>
> Somewhere I read that the cursor is freed not when close is called,
> but only if the resultset is garbage collected.
>
> I'm desesperated. Using the v$open_cursor view I can see the querys
> which open the cursors but I think that are internal cursors. I'm sure
> that I close all
> the ResultSets ant Statements.
>
> Anybody could help me?
>
> Thanks in Advance,
> Karlos.
Received on Mon Aug 11 2003 - 16:39:49 CDT
![]() |
![]() |