Package overit.geocall.sql
Class ElasticConnectionPool
Database connection pool based on the apache commons pool implementation.
In particular this pool allows you to manage a variable number of connections to the database, opening new ones as
needed.
It is possible to configure a maximum number of open connections, but also a minimum number to ensure that open sockets are always available to the db.
The pool uses a mechanism for automatically removing unused connections to avoid having to keep many sockets open unnecessarily.
-
Field Summary
Fields inherited from class overit.geocall.sql.ConnectionPool
_dbom, _dbSetupStatments, _maxQueryRows, _name, _ph, _qh, cross, encryptionKey, TYPE_DATASOURCE, TYPE_ELASTIC, TYPE_STANDARD -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of an ElasticConnectionPool given the database references and the number of the minimum and maximum available connections. -
Method Summary
Modifier and TypeMethodDescriptionvoiddisconnect(long id) Close the connection identified by a specific id valuevoiddispose()Disposes the ConnectionPool.getConnection(String activity) Extracts a Connection from the poolReturns the informations about the connections of the poolgetDate()Returns the Date of the max number of utilized connectionsintgetMax()Returns the max number of utilized connectionsintlocked()Returns the number of locked connections, i.e. the connections that are currently used by the applicationvoidReleases a Connection previously extracted withgetConnection()voidresetMax()Resets the max number of utilized connectionsintsize()Returns the size of the ConnectionPoolMethods inherited from class overit.geocall.sql.ConnectionPool
getCross, getDBObjectMap, getDBType, getEncryptionKey, getHistory, getMaxQueryRows, getName, getParameters, getQueryHistory, setCross, setDBType, setEncryptionKey
-
Constructor Details
-
ElasticConnectionPool
Creates a new instance of an ElasticConnectionPool given the database references and the number of the minimum and maximum available connections.- Parameters:
config- instance used to retrieve the pool's configuration parameters- Throws:
Exception- in case of some problem during the pool's initialization
-
-
Method Details
-
getMax
public int getMax()Returns the max number of utilized connections- Returns:
- The max number of utilized connections
-
getDate
Returns the Date of the max number of utilized connections- Returns:
- The Date of the max number of utilized connections
-
resetMax
public void resetMax()Resets the max number of utilized connections -
getConnection
Description copied from class:ConnectionPoolExtracts a Connection from the pool- Specified by:
getConnectionin classConnectionPool<ElasticPooledConnection>- Parameters:
activity- The motivation / operation for which the extract request originates- Returns:
- The Connection extracted
- Throws:
SQLException- If there is an error during the extraction, anSQLExceptionwill be raised
-
releaseConnection
Description copied from class:ConnectionPoolReleases a Connection previously extracted withgetConnection()- Specified by:
releaseConnectionin classConnectionPool<ElasticPooledConnection>- Parameters:
conn- The Connection to release- Throws:
SQLException- If there is an error during the release, anSQLExceptionwill be raised
-
getConnectionInfo
Description copied from class:ConnectionPoolReturns the informations about the connections of the pool- Specified by:
getConnectionInfoin classConnectionPool<ElasticPooledConnection>- Returns:
- The List that contains the informations about the connections
-
locked
public int locked()Description copied from class:ConnectionPoolReturns the number of locked connections, i.e. the connections that are currently used by the application- Specified by:
lockedin classConnectionPool<ElasticPooledConnection>- Returns:
- The number of currently locked connections
-
size
public int size()Description copied from class:ConnectionPoolReturns the size of the ConnectionPool- Specified by:
sizein classConnectionPool<ElasticPooledConnection>- Returns:
- The number of Connection of this instance of ConnectionPool
-
disconnect
public void disconnect(long id) Close the connection identified by a specific id value- Parameters:
id- the connection identifier
-
dispose
public void dispose()Description copied from class:ConnectionPoolDisposes the ConnectionPool. Use this method when the object is no longer needed, for example when the application is closed- Overrides:
disposein classConnectionPool<ElasticPooledConnection>
-