The following description applies to the connection pooling model. The alternative model is the connection manager (not recommended).
IBM WebSphere Application Server establishes and maintains pools of connections as specified by the administrator.
After the connections are set up, the product manages them by parceling out connections in response to user requests and then performing housekeeping operations to maintain a balance between available connections and demand for connections. This ensures that an existing connection is available when a servlet or application server needs a connection.
For example, the connection pool periodically identifies idle or orphaned connections. It terminates idle connections and returns orphaned connections to the connection pool. This means that fewer connections are available (and fewer resources are used) when demand for connections is low.
An idle connection is one that has been free in the connection pool for the amount of time specified in the idleTimeout property of the data source. Idled connections are removed from the pool and closed to the database.
A connection is orphaned when its owning servlet or application has not used the connection for longer than the amount of time specified in the orphanTimeout property of the data source. Orphaned connections are returned to the pool of free connections. Any use of an orphaned connection or its associated JDBC resources results in a StaleConnectionException being thrown.
At the end of a transaction, the transaction manager closes all connections that have enlisted in that transaction. This enables the transaction manager to ensure that connections are not held for long periods of time, which tends to force the pool size up. As a result, an application cannot obtain a connection in one transaction and try to use it in another transaction. If the application tries this, a StaleConnectionException is thrown, because the connection is already closed.
However, if the application must hold a connection outside the scope of the transaction, the administrator can configure a datasource not to automatically clean up the connections it has allocated. To do this, the administrator sets the disableAutoConnectionCleanup property on a datasource to true. This property should be enabled only if the application will always close its own connections. Otherwise, the pool will quickly run out of connections.
If your application typically requires two or more connections to the same database manager, consider the following: