title: Oracle connection not closing in Java Application
body: <p>I have a connection leak in some older Java web applications which do not utilize connection pooling.
  Trying to find the leak is hard because IT will not grant me access to v$session <code>SELECT Count(*) FROM v$session;</code></p>
  
  <p>So instead I am trying to debug with System.out statements.  Even after closing the connection <code>conn.close();</code> when I print conn to the System log file it gives me the connection object name. </p>
  
  <pre><code>try { 
      Connection conn;
      conn.close() 
      } 
  catch (SQLException e) { }
  finally { 
      if (conn != null) {
          try {
             System.out.println("Closing the connection"); 
             conn.close();
             }
          catch (Exception ex) 
              {
              System.out.println("Exception is " + ex); 
              }
       }
   }
  // I then check conn and it is not null and I can print the object name.
      if (conn != null) {
              System.out.println("Connection is still open and is " + conn); 
      }
  </code></pre>
  
  <p>however if I also add <code>conn = null;</code> below the <code>conn.close();</code> statement the connection now seems closed.  So my question is does conn.close(); actually release my connection or do I also have to make it null to really release my connection.  Like I said it is really hard for me to determine if the connection is actually released without being able to query v$session.  Is there snippet of java code which can give me my open connections??</p>
  
  <p>It's probably educational at this point because I plan to refactor these applications to use connection pooling but I'm looking for a quick bandaid for now.</p>