TICS Coding Standard Viewer 
TIOBE Software Quality Framework
Print-friendly version
©TIOBE Software www.tiobe.com
 
TIOBE - Java Coding Standard
Search

Rule:  Design11Checked automatically with code checker

Synopsis:Ensure that resources are closed after use
Language:Java
Severity Level:1
Category:Design


Description:
Ensure that resources (like Connection, Statement, and ResultSet objects) are always closed after use.
public class Bar {
 public void foo() {
  Connection c = pool.getConnection();
  try {
    // do stuff
  } catch (SQLException ex) {
    // handle exception
  } finally {
    // oops, should close the connection using 'close'!
    // c.close();
  }
 }
}