>
> Good call Ana; and the following "template" is how you should
> implement all
> your jdbc calls:
>
>
> Connection conn                 = null;
> PreparedStatement stmt  = null;
> ResultSet results               = null;
> try
> {
>         conn = dataSource.getConnection();
>         stmt = conn.getPreparedStatement();
>         results = stmt.execute();
> }
> catch(SQLException se)
> {
> }
> finally
> {
>         if(results !=null) results.close();
>         if(stmt !=null) stmt.close();
>         if(conn !=null) conn.close();
> }
>
While others also protect the calls in the finally block:
finally {
   try { results.close(); } catch (Exception ignore) {}
   try { stmt.close(); } catch (Exception ignore) {}
   try { conn.close(); } catch (Exception ignore) {}
}

This prevents a leak in the (unlikely) case that results.close() throws an
exception.

- Avi
--
s/\be(\w+)/e-\1/g;

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to