title: How to avoid sonar error "use try-with-resources or close this ... in a "finally" clause" if custom close method is used (java 6)?
body: <p>Here's the code:</p>
  <pre><code>Connection connection = null;
      try {
          connection = createConnection();
          String sql = String.format(STRING_FOR_PROCEDURE, name);
          connection.createStatement().execute(sql);
          connection.commit();
      } catch (Exception e) {
          throw new DatabaseServiceException(e.getMessage(), e);
      } finally {
          closeConnection(connection);
      }
  </code></pre>
  <p>I suppose sonar wants me to close connection in block &quot;finally&quot; with something like this:</p>
  <pre><code>connection.close();
  </code></pre>
  <p>But I use custom method for this which is:</p>
  <pre><code>    protected void closeConnection(Connection connection) {
      try {
          if (connection != null) {
              connection.close();
          }
      } catch (SQLException ex) {
          LOGGER.log(Level.SEVERE, null, ex);
      }
  }
  </code></pre>
  <p>This method needs to be used in current class. But I receive sonar blocker &quot;use try-with-resources or close this statement in a &quot;finally&quot; clause&quot;.
  Any ideas how to fix it?</p>