Package overit.geocall.sql
Class StandardConnectionPool
java.lang.Object
overit.geocall.sql.ConnectionPool<StandardPooledConnection>
overit.geocall.sql.StandardConnectionPool
Class that implements the standard
ConnectionPool-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<DirectConnection> protected Dateprotected intprotected List<DirectConnection> protected intprotected final ObjectFields inherited from class overit.geocall.sql.ConnectionPool
_dbom, _dbSetupStatments, _maxQueryRows, _name, _ph, _qh, cross, encryptionKey, TYPE_DATASOURCE, TYPE_ELASTIC, TYPE_STANDARD -
Constructor Summary
ConstructorsConstructorDescriptionStandardConnectionPool(String name, String driver, String url, String user, String password, String testStatement, String script, StringGetter parameters, int number) Creates a StandardConnectionPool with the desired number of connections -
Method Summary
Modifier and TypeMethodDescriptionvoiddisconnect(int i) Close a connectionvoiddispose()Disposes the StandardConnectionPool.getConnection(int i, String activity) Extract a free connection from the poolgetConnection(String activity) Extract a free connection from the poolReturns the informations (seePooledConnectionInfo) about all the connection of the poolgetDate()Returns the Date of the max number of utilized connectionsintgetMax()Returns the max number of utilized connectionsbooleanisFree(int i) Checks if the desired connection is freeintlocked()Return the number of locked (not free) connections of the poolvoidReleases a connection previously extracted withgetConnection()voidresetMax()Resets the max number of utilized connectionsintsize()Returns the size of the ConnectionPool, i.e. the number of its connectionsMethods inherited from class overit.geocall.sql.ConnectionPool
getCross, getDBObjectMap, getDBType, getEncryptionKey, getHistory, getMaxQueryRows, getName, getParameters, getQueryHistory, setCross, setDBType, setEncryptionKey
-
Field Details
-
_free
-
_all
-
_sem
-
_dim
protected int _dim -
_max
protected int _max -
_date
-
-
Constructor Details
-
StandardConnectionPool
public StandardConnectionPool(String name, String driver, String url, String user, String password, String testStatement, String script, StringGetter parameters, int number) throws ClassNotFoundException Creates a StandardConnectionPool with the desired number of connections- Parameters:
name- The name of the ConnectionPool. If the name starts with "Service" the pool will be used for the service communication, for example for theStaticViewloading.driver- The name of the JDBC driverurl- The address of the databaseuser- The username for the database accesspassword- The password for the database accesstestStatement- A test command for the database accessscript- Script that will be executed in the connection phaseparameters- TheStringGetterthat contains the database parametersnumber- The number of connections of the pool- Throws:
ClassNotFoundException- The search for the correct JDBC driver can raise aClassNotFoundException
-
-
Method Details
-
getConnectionInfo
Returns the informations (seePooledConnectionInfo) about all the connection of the pool- Specified by:
getConnectionInfoin classConnectionPool<StandardPooledConnection>- Returns:
- The List of
PooledConnectionInfoof all the connections
-
isFree
public boolean isFree(int i) Checks if the desired connection is free- Parameters:
i- The index that identifies the connection- Returns:
trueif the connections is free,falseotherwise
-
releaseConnection
Releases a connection previously extracted withgetConnection()- Specified by:
releaseConnectionin classConnectionPool<StandardPooledConnection>- Parameters:
spc- The Connection to release- Throws:
SQLException- If there is an error during the release, anSQLExceptionwill be raised
-
size
public int size()Returns the size of the ConnectionPool, i.e. the number of its connections- Specified by:
sizein classConnectionPool<StandardPooledConnection>- Returns:
- The number of connections of this instance of StandardConnectionPool
-
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
Extract a free connection from the pool- Parameters:
i- The index of the connection to be extractedactivity- Motivation / operation from which the extract request originates- Returns:
- A free connection, ready to use
- Throws:
SQLException- If there is an error during the extraction, anSQLExceptionwill be raised
-
getConnection
Extract a free connection from the pool- Specified by:
getConnectionin classConnectionPool<StandardPooledConnection>- Parameters:
activity- Motivation / operation from which the extract request originates- Returns:
- A free connection, ready to use
- Throws:
SQLException- If there is an error during the extraction, anSQLExceptionwill be raised
-
disconnect
public void disconnect(int i) Close a connection- Parameters:
i- The index of the connection to be closed
-
dispose
public void dispose()Disposes the StandardConnectionPool. Use this method when the object is no longer needed, for example when the application is closed- Overrides:
disposein classConnectionPool<StandardPooledConnection>
-
locked
public int locked()Return the number of locked (not free) connections of the pool- Specified by:
lockedin classConnectionPool<StandardPooledConnection>- Returns:
- The number of locked connections
-