org.jminor.common.db.pool
Interface ConnectionPool


public interface ConnectionPool

Defines a simple connection pool.


Method Summary
 void close()
          Closes this connection pool, disconnection connections as they are checked in
 int getCleanupInterval()
           
 PoolableConnection getConnection()
          Fetches a connection from the pool.
 int getConnectionTimeout()
           
 int getMaximumCheckOutTime()
           
 int getMaximumPoolSize()
           
 int getMaximumRetryWaitPeriod()
           
 int getMinimumPoolSize()
           
 int getNewConnectionThreshold()
           
 ConnectionPoolStatistics getStatistics(long since)
          Retrives usage statistics for the connection pool since time since.
 User getUser()
           
 boolean isCollectFineGrainedStatistics()
           
 boolean isEnabled()
           
 void resetStatistics()
          Resets the collected usage statistics
 void returnConnection(PoolableConnection connection)
          Return the given connection to the pool.
 void setCleanupInterval(int poolCleanupInterval)
           
 void setCollectFineGrainedStatistics(boolean value)
          Specifies whether or not fine grained usage statistics should be collected.
 void setConnectionTimeout(int timeout)
           
 void setEnabled(boolean enabled)
           
 void setMaximumCheckOutTime(int value)
           
 void setMaximumPoolSize(int value)
           
 void setMaximumRetryWaitPeriod(int maximumRetryWaitPeriod)
           
 void setMinimumPoolSize(int value)
           
 void setNewConnectionThreshold(int value)
           
 

Method Detail

getUser

User getUser()
Returns:
the user this connection pool is based on.

getConnection

PoolableConnection getConnection()
                                 throws ClassNotFoundException,
                                        SQLException
Fetches a connection from the pool.

Returns:
a database connection retrieved from the pool
Throws:
ConnectionPoolException.NoConnectionAvailable - in case the maximum check out time is exceeded
ClassNotFoundException - in case the JDBC driver class is not found
SQLException - in case of a database exception
IllegalStateException - if the pool is closed
See Also:
setMaximumCheckOutTime(int)

returnConnection

void returnConnection(PoolableConnection connection)
Return the given connection to the pool. If the pool has been closed the connection is disconnected and discarded.

Parameters:
connection - the database connection to return to the pool

close

void close()
Closes this connection pool, disconnection connections as they are checked in


getStatistics

ConnectionPoolStatistics getStatistics(long since)
Retrives usage statistics for the connection pool since time since.

Parameters:
since - the time from which statistics should be retrieved
Returns:
connection pool usage statistics

resetStatistics

void resetStatistics()
Resets the collected usage statistics


isCollectFineGrainedStatistics

boolean isCollectFineGrainedStatistics()
Returns:
true if fine grained pool usage statistics should be collected.
See Also:
getStatistics(long), ConnectionPoolStatistics.getFineGrainedStatistics()

setCollectFineGrainedStatistics

void setCollectFineGrainedStatistics(boolean value)
Specifies whether or not fine grained usage statistics should be collected.

Parameters:
value - the value
See Also:
getStatistics(long), ConnectionPoolStatistics.getFineGrainedStatistics()

isEnabled

boolean isEnabled()
Returns:
true if this pool is enabled, false otherwise

setEnabled

void setEnabled(boolean enabled)
Parameters:
enabled - true to enable this pool, false to disable

getCleanupInterval

int getCleanupInterval()
Returns:
the pool cleanup interval in milliseconds

setCleanupInterval

void setCleanupInterval(int poolCleanupInterval)
Parameters:
poolCleanupInterval - the pool cleanup interval in milliseconds

getConnectionTimeout

int getConnectionTimeout()
Returns:
the connection timeout in milliseconds

setConnectionTimeout

void setConnectionTimeout(int timeout)
Parameters:
timeout - the connection timeout in milliseconds

getMaximumRetryWaitPeriod

int getMaximumRetryWaitPeriod()
Returns:
the maximum number of milliseconds the pool waits between checkout retries

setMaximumRetryWaitPeriod

void setMaximumRetryWaitPeriod(int maximumRetryWaitPeriod)
Parameters:
maximumRetryWaitPeriod - the maximum number of milliseconds the pool waits between checkout retries

getMinimumPoolSize

int getMinimumPoolSize()
Returns:
the minimum number of connections to keep in the pool

setMinimumPoolSize

void setMinimumPoolSize(int value)
Parameters:
value - the minimum number of connections to keep in the pool
Throws:
IllegalArgumentException - if value is less than 0 or larger than maximum pool size

getMaximumPoolSize

int getMaximumPoolSize()
Returns:
the maximum number of connections this pool can create

setMaximumPoolSize

void setMaximumPoolSize(int value)
Parameters:
value - the maximum number of connections this pool can create
Throws:
IllegalArgumentException - if value is less than 1 or less than minimum pool size

getMaximumCheckOutTime

int getMaximumCheckOutTime()
Returns:
the maximum number of milliseconds to retry connection checkout before throwing an exception
See Also:
ConnectionPoolException.NoConnectionAvailable

setMaximumCheckOutTime

void setMaximumCheckOutTime(int value)
Parameters:
value - the maximum number of milliseconds to retry connection checkout before throwing an exception
Throws:
IllegalArgumentException - if value is less than 0

getNewConnectionThreshold

int getNewConnectionThreshold()
Returns:
the time to wait before a new connection is created

setNewConnectionThreshold

void setNewConnectionThreshold(int value)
Parameters:
value - the time to wait before creating a new connection in ms
Throws:
IllegalArgumentException - in case value is negative or larger than maximumCheckOutTime