title: Resource leak warning in eclipse
body: <p>In <code>Eclipse</code> I received a warning <code>Resource leak: 'ps' is not closed at this location</code> that I don't understand.</p>
  
  <p>In my <code>Java</code> code I declare the <strong>"ps"</strong> as a Prepared Statement and I use (and close) it many times. Then I've the following sequence:</p>
  
  <pre><code>try {
      if(condition) {
          ps = c.prepareStatement("UPDATE 1 ...");
      } else {
          ps = c.prepareStatement("UPDATE 2 ...");
      }
      ps.executeUpdate();
  } catch (SQLException e) {
      // exception handling
  } finally {
      if (null != ps) 
          try { 
              ps.close(); 
          } catch (SQLException e) { 
              // exception handling
          };
  }
  </code></pre>
  
  <p>The "Resource leak"-Warning comes on the "Update"-Statement in the else section.
  If I set <code>ps = null</code> before I start the try block, there is no warning.</p>
  
  <p>If the second UPDATE-Statement is commented out, no warning will be shown.</p>
  
  <p>Is that an understanding or a java / eclipse problem?</p>