Hi guys,

We've been using, very succesfully, this strategy:

        public void foo()
        throws SQLException {
                Connection conn = null;
                Statement stmt = null;
                ResultSet rs = null;
                try {
                        conn = getConnection();
                        stmt = conn.createStatement();
                        ...
                        return;
                } finally {
                        if (rs   != null) rs.close();
                        if (stmt != null) stmt.close();
                        if (conn != null) conn.close();
                }
        }

This guarantees that no connection, statement, or resultset will remain open, 
regardless of exceptions or returns.

Regards,
Rog�rio Gatto


> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's
> Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On
> Behalf Of Rhys
> Lewis
> Sent: Monday, February 22, 1999 6:17 PM
> To: [EMAIL PROTECTED]
> Subject: Re: JDBC & Oracle - max. open cursors exceeded
>
>
> Yes - I had this problem when I was not closing connections and result
> sets properly.
>
> Rhys Lewis
>
> -----Original Message-----
> From: shaoming [mailto:[EMAIL PROTECTED]]
> Sent: Monday, February 22, 1999 2:44 PM
> Subject: JDBC & Oracle - max. open cursors exceeded
>
>
> Hi!
>
> I'm writing a servlet which, using JDBC, connect to a Oracle 8 DB
> (NT platform) to insert, update and delete records.
>
> It works fine for a while. After long usage or multiple user access,
> the error
>
>         "SQLException  - ORA-01000: maximum open cursors exceeded"
>
> is shown.
>
> Anyone has this same problem? Please help.
>
> Thanks,
> /shaoming
>
> ______________________________________________________________
> _____________
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to