Hi All,
I have Database code that find bugs is reporting as a
potential problem, though I can’t see anything wrong with it. The code
follows this pattern
public void dropTestTable() {
Statement stmt = null;
try{
stmt = con.createStatement();
stmt.executeUpdate( "DROP TABLE TEST" );
}catch( SQLException e ) {
e.printStackTrace();
}finally{
SQLUtils.closeResources(
stmt );
}
}
The SQLUtils.closeResources method is
public static void closeResources( Statement
... stmts ){
for( Statement stmt : stmts ){
try {
if( stmt != null )
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
Findbugs is
telling me that the method may fail to close the database resource. Is there
something obvious that I’m missing?
Thanks
Mark Hillary