commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Graham <grahamdavid1...@yahoo.com>
Subject Re: [dbutils] Exception handling
Date Mon, 03 Nov 2003 00:39:44 GMT

--- Juozas Baliuka <baliuka@mail.lt> wrote:
> 
> Looks like it is not a very good practice:
> 
>  /**
>      * Close a <code>Connection</code>, avoid closing if null and hide
>      * any exceptions that occur.
>      */
>     public static void closeQuietly(Connection conn) {
>         try {
>             close(conn);
>         } catch (SQLException sqle) {
>             // quiet
>         }
>     }

I agree that this isn't the best idea so I replaced calls to
closeQuietly() with DbUtils.close() in QueryRunner.

David

> 
> Some "clever" Connection implememtation can throw meaningfull
> exceptions:
> 
> if(Thread.currentThread() != openThread ){
>  throw new SQLException( Thread.currentThread() + " doe's not owns
> connection" );
> }
> 
> Logging is not the best practice to handle exeptions,
> I think it is better to clear all resources in nested finally blocks and
> delegate exeption handling for API user, or add new callback interface 
> with
> method
> "void handleThrowable(Throwable t)".
> 
> BTW "closeQuietly" hides SQLException only on "any exceptions that
> occur".
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
> 


__________________________________
Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

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


Mime
View raw message