Your code would not catch a SQLException. You need
public void dostuff (HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException, SQLException {
try {
code here
} catch (SQLException e) {
do error logging
you could throw the SQLException back to whomever called this method at
this point.
} finally {
close all connections/statements/resultsets
}
}
Rob
> -----Original Message-----
> From: Sam Rose [SMTP:[EMAIL PROTECTED]]
> Sent: Wednesday, February 24, 1999 9:38 AM
> To: [EMAIL PROTECTED]
> Subject: SQL Exceptions - finally or catch?
>
> Sorry about the re-post just that I didn't put down the right subject
> :-)
>
> 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
>
>
> > -----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
>
> __________________________________________________________________________
> _
> 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