Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If we assume a (basic) <code>DataSource</code> (that is: one that does not do connection pooling), then you obtain a physical connection that is the same as one obtained from <code>DriverManager</code> (some drivers even internally use DriverManager from the DataSource, or a DataSource from DriverManager). So those connections will behave identically.</p> <p>Now if we assume a <code>DataSource</code> that provides connection pooling, then the DataSource itself uses a <code>ConnectionPoolDataSource</code> (or a similar internal mechanism) to obtain a <code>PooledConnection</code>. This PooledConnection manages the actual physical connection to the database.</p> <p>When a user requests a connection from the DataSource, the DataSource will checkout a PooledConnection, and ask it for a <code>Connection</code>. The PooledConnection will then create a logical connection that uses or wraps the physical connection (eg using a Proxy). The DataSource will return that logical connection to the user.</p> <p>To the user the logical connection should behave identical to a physical connection in all aspects. So when a user closes the connection, that logical connection and all dependent JDBC objects will be closed and behave identical to a physical connection close.</p> <p>JDBC 4.1 section 11.1 says:</p> <blockquote> <p>Connection pooling is completely transparent to the client: A client obtains a pooled connection and uses it just the same way it obtains and uses a non pooled connection.</p> </blockquote> <p>And section 11.4:</p> <blockquote> <p>If the application attempts to reuse the logical handle, the Connection implementation throws an SQLException.</p> </blockquote> <p>and</p> <blockquote> <p>For a given PooledConnection object, only the most recently produced logical Connection object will be valid. Any previously existing Connection object is automatically closed when the associated PooledConnection.getConnection method is called.</p> </blockquote> <p>In the background however, when the logical connection is closed, the PooledConnection will signal the DataSource that it is available for reuse, and the DataSource will then return it to the connection pool, or close the PooledConnection (which closes the physical connection) if it no longer needs the connection.</p> <p>The DataSource can also forcefully revoke a connection from a user (eg when a connection is checked out too long, etc), by asking the PooledConnection to close the logical connection.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload