commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Charles Burdick <charles_burd...@yahoo.com>
Subject Re: [dbcp]: Oracle "too many open cursors error"
Date Tue, 07 May 2002 18:53:07 GMT
I've run into this before as well.  Here's your two options as I see
it.

Option 1:
Don't pool the prepared statements (an option in the JOCL
configuration) and use a bound pool for the connections.
Pros: Only need to change the configuration, not the code.
Cons: Don't get speed enhancement on pooling prepared statements.

Option 2:
Explicitly close the ResultSet and PreparedStatement before returning
the Connection as in the following example.  This must be done in all
code that accesses the database.
Pros: Get all performance benefits from pooling. Longer term solution.
Cons: Need to recompile and redeploy

Connection conn = null;
PreparedStatement stmt = null;
ResultSet rset = null;
try {
   conn = DriverManager.getConnection(/* YOUR POOL SPEC */);
   stmt = conn.prepareStatement(/* YOUR STMT */);

   // Set params to stmt

   rset = stmt.executeQuery();

   // Handle result set
} catch (SQLException e) {
   // handle exception
} finally {
   try { rset.close(); } catch (Throwable t) {} // Clears cursors
   try { stmt.close(); } catch (Throwable t) {} // Returns to pool
   try { conn.close(); } catch (Throwable t) {} // Returns to pool
}

Hope that helps,
Chuck

--- Bill Schneider <bschneider@vecna.com> wrote:
> (please forgive my last message that got cut off)
> 
> I've been using the dbcp BasicDataSourceFactory with Tomcat, as a
> replacement for Tyrex brokenness.  I ran into some trouble with it
> under
> heavy load: after running it for a while I end up with an Oracle "too
> many
> open cursors error".

[SNIP]
 
> -- Bill


__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message