JavaXT Documentation

ConnectionPool Class

A lightweight, high-performance JDBC connection pool manager with health monitoring, validation caching, and lock-free concurrent connection management.

Constructors

ConnectionPool( Database database, int maxConnections )
ConnectionPool( Database database, int maxConnections, int timeout )
ConnectionPool( Database database, int maxConnections, Map options )
ConnectionPool( ConnectionPoolDataSource dataSource, int maxConnections )
ConnectionPool( ConnectionPoolDataSource dataSource, int maxConnections, Integer timeout )
ConnectionPool( ConnectionPoolDataSource dataSource, int maxConnections, Map options )

Public Methods

getConnection( ) returns Connection
Retrieves a connection from the connection pool. If all the connections are in use, the method waits until a connection becomes available or timeout seconds elapsed. When the application is finished using the connection, it must be closed in order to return it to the pool.
getActiveConnections( ) returns int
Returns the number of active (open) connections of this pool.

This is the number of Connection objects that have been issued by {@link #getConnection()}, for which Connection.close() has not yet been called.

getInactiveConnections( ) returns int
Returns the number of inactive (unused) connections in this pool.

This is the number of internally kept recycled connections, for which Connection.close() has been called and which have not yet been reused.

getMaxConnections( ) returns int
Returns the configured maximum number of connections in the pool.
getConnectionPoolDataSource( ) returns ConnectionPoolDataSource
Returns the ConnectionPoolDataSource backing this connection pool.
getTimeout( ) returns int
Returns the maximum time to wait for a free connection, in seconds.
getConnectionIdleTimeout( ) returns int
Returns the connection idle timeout in seconds. Connections that remain unused in the pool for more than the idle timeout are automatically removed. This prevents accumulation of stale connections that may have been closed by the database server. Note that this only affects connections sitting idle in the pool, not active connections being used by your application.
getConnectionMaxAge( ) returns long
Returns the maximum connection age in seconds.
getValidationQuery( ) returns String
Returns the validation query used to periodically test connections in the pool.
getValidationTimeout( ) returns int
Returns the interval used to execute validation queries in seconds.
close( ) returns void
Closes all unused pooled connections and shuts down the connection pool. After calling this method, clients can no longer get new connections via getConnection().
isClosed( ) returns boolean
Returns true if the connection pool has been closed.
forceHealthCheck( ) returns void
Synchronously runs a single health-check pass. In normal operation the same health-check runs on a background scheduler every 30 seconds. Safe to call at any time.
getPoolStatistics( ) returns PoolStatistics
Returns current pool statistics for monitoring.

Public Classes