title: Connection.close vs. PooledConnection.close
body: <p>I'm reading <code>Java Data Access—JDBC, JNDI, and JAXP</code> about <code>Connection, PooledConnection</code> interfaces. As I understand <code>Connection</code> returned by <code>PooledConnection</code> represents a "logical" connection. <code>PooledConnection</code> - itself represents "physical". What's the difference between them concerning closing?</p>
  
  <blockquote>
    <p>Calling the close() method on a standard Connection object closes the
    physical connection. In contrast, calling the close() method on a
    logical Connection object returns the logical connection to the pool
    for other clients to use.</p>
  </blockquote>
  
  <ol>
  <li><p>My first question is: Should I invoke PooledConnection.close()? If i'm right, I don't want physical connection closing, I only want to check the physical connection out (to release it) to its pool. </p></li>
  <li><p>The second question: I don't see why I need to call <code>Connection.close()</code> on the object, returned by <code>PooledConnection.getConnection()</code></p></li>
  <li><p>If you look at the example: <a href="http://www.java2s.com/Code/Java/Database-SQL-JDBC/PooledConnectionExample.htm" rel="nofollow">PooledConnection example</a> only <code>Connection.close()</code> method is invoked, but not <code>PooledConnection.close()</code>. Please comment it.</p></li>
  <li><p>According to the official documentation: <a href="http://download.oracle.com/javase/6/docs/api/javax/sql/PooledConnection.html#close%28%29" rel="nofollow">PooledConnection.close</a> PooledConnection actually closes the physical connection that this PooledConnection object represents. But as I understand connection pool main (one of main) purpose - keep physical connections, without closing/creating it. According to documentation if I run PooledConnection.close() then connection pool will have to recreate it again. Could you comment this also.</p></li>
  </ol>
  
  <p>Thanks.</p>