Sorry about the re-post just that I didn't put down the right subject
:-) , and if the one before this appears, I don't understand why as I
got a message saying mail delivery failure. Anyway :-
:
Hi,
I was looking through this code(from gatto@widesoft) , and was
wondering where the catch code would go.
I am a newcomer to Java and am not sure if by having the throws clause
is as efficient/bad/or same as the try/catch syntax.
Would my code see below actually catch an SQL exception or not?
I was wondering you could shed some light on the matter for me
please.
public class newlite extends HttpServlet {
public void dostuff (HttpServletRequest req, HttpServletResponse
res)
throws ServletException, IOException, SQLException {
Connection con = null;
Statement stmt = null;

CODE
return;
        }
finally {
if (stmt != null) stmt.close(); if (con != null) con.close();
                }


-----Original Message-----
From:   Rogerio Meneguelli Gatto [SMTP:[EMAIL PROTECTED]]
Sent:   Monday, February 22, 1999 9:45 PM
To:     [EMAIL PROTECTED]
Subject:        Re: JDBC & Oracle - max. open cursors exceeded

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

___________________________________________________________________________
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