commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Juozas Baliuka" <bali...@centras.lt>
Subject Re: commons dbcp or pool problems
Date Fri, 22 Feb 2002 20:01:42 GMT
<skip> 
> which won't do what we want if either of the first two lines throws an
> Exception.  I use this idiom:
> 
> } finally {
>   try { resultset.close(); } catch(Exception e) { }
>   try { statement.close(); } catch(Exception e) { }
>   try { connection.close(); } catch(Exception e) { }
> }
> 
> and don't worry about null or anything else.)
> 
>  - Rod
Yes it is good idea. I can recoment something like this

void closeJDBCObject(Object obj){
try{
 if (obj != null){ // don't need this
    if ( obj instanceof Connection ){
         ((Connection)obj).close();
      }
   else if ( obj instanceof ResultSet ){
 ...............................................

  }
}catch( Throwable  ignore){

 }

} 


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


Mime
View raw message