skip to main content
DataDirect Connection Pooling : Methods for Configuring the Connection Pool : Configuring Pool Size
 

Try DataDirect Cloud Now

Configuring Pool Size

Set the maximum pool size using the PooledConnectionDataSource.setMaxPoolSize() method. For example, the following code sets the maximum pool size to 10 connections:
ds.setMaxPoolSize(10);
You can control how the Pool Manager implements the maximum pool size by setting the PooledConnectionDataSource.setMaxPoolSizeBehavior() method:
*If setMaxPoolSizeBehavior(softCap), the number of active connections can exceed the maximum pool size, but the number of idle connections for each user in the pool cannot exceed this limit. If a user requests a connection and an idle connection is unavailable, the Pool Manager creates a new connection for that user. When the connection is no longer needed, it is returned to the pool. If the number of idle connections exceeds the maximum pool size, the Pool Manager closes idle connections to enforce the pool size limit. This is the default behavior.
*If setMaxPoolSizeBehavior(hardCap), the total number of active and idle connections cannot exceed the maximum pool size. Instead of creating a new connection for a connection request if an idle connection is unavailable, the Pool Manager queues the connection request until a connection is available or the request times out. This behavior is useful if your client or application server has memory limitations or if the data store server is licensed for only a certain number of connections.
See PooledConnectionDataSource for more information about these methods.