Juozas Baliuka
Fri, 22 Feb 2002 10:45:57 -0800
<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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>