public class TConnectionPoolManager
extends java.lang.Object
TConnectionPoolManager manages one or more pools of connections. Two types of
connection pools exist. One type only pools TConnection Java objects, the other also pools
the underlying Tamino physical connections. The first variant of the connection pool only
remains there for upward compatibility reasons. It is strongly recommended to use the
second variant including the pooling of Tamino physical connections. This kind of pooling
can significanlty improve the performance of an application.
You can obtain pooled connections from a specific pool from the manager by invoking
TConnectionPoolManager.getConnection(). Once a pooled connection is no longer used,
you must return it to the pool by closing it.
The connection pool manager waits timeOut seconds for a connection to be returned to the pool when all connections of a pool are in use and the maximum limit (MaxConnections) of connections is already reached. If the timeOut is elapsed and still no connection is available, an exception will be thrown. Note that by setting the timeOut to 0, an exception will be thrown immediately.
This class implements the singleton pattern, i.e. there is always only one instance of this class available.
It is recommended to configure connection pools by invoking the addConnectionPool() method which requires a TConnectionPoolDescriptor object describing the properties of the pool and its connections. This method also guarantess that Tamino physical connections are pooled. When configuring such a pool it is important to realize that all connections managed by that pool have the the same values for all session parameters, like lock mode, transaction timeout, etc. These paremeters are only set once based on their setting in the TConnectionPoolDescriptor used t create the pool. Only the _isolationLevel parameter may be overwritten by using the setIsolationDegree() method immediately after a getConnection and before its first usage.
For upward compatibility reasons you can still also configure the TConnectionPoolManager in the following ways:<ManagedConnectionPools> <ConnectionPool name="MyPool"> <DatabaseURI>myDatabaseURI</DatabaseURI> <UserId>myUserIdIfGiven</UserId> <Domain>myDomainIfGiven</Domain> <Password>myPasswordIfGiven</Password> <InitConnections>myInitConnectionsAsAnInteger</InitConnections> <MaxConnections>myMaxConnectionsAsAnInteger</MaxConnections> <TimeOut>myTimeoutAsSeconds</TimeOut> </ConnectionPool> </ManagedConnectionPools>The element ManagedConnectionPools can contain multiple ConnectionPool elements each of which describes a managed pool.
Modifier and Type | Method and Description |
---|---|
boolean |
addConnectionPool(java.lang.String poolName,
java.lang.String databaseURI,
java.lang.String user,
java.lang.String password,
int maxConnections,
int initConnections,
int timeOut)
Add a connection pool to the list of managed pools.
|
boolean |
addConnectionPool(java.lang.String poolName,
java.lang.String databaseURI,
java.lang.String user,
java.lang.String password,
int maxConnections,
int initConnections,
int timeOut,
java.util.Locale locale)
Add a connection pool to the list of managed pools.
|
boolean |
addConnectionPool(java.lang.String poolName,
java.lang.String databaseURI,
java.lang.String domain,
java.lang.String user,
java.lang.String password,
int maxConnections,
int initConnections,
int timeOut)
Add a connection pool to the list of managed pools.
|
boolean |
addConnectionPool(java.lang.String poolName,
java.lang.String databaseURI,
java.lang.String domain,
java.lang.String user,
java.lang.String password,
int maxConnections,
int initConnections,
int timeOut,
java.util.Locale locale)
Add a connection pool to the list of managed pools.
|
boolean |
addConnectionPool(java.lang.String poolName,
TConnectionPoolDescriptor descriptor)
Adds a connection pool to the list of managed pools.
|
boolean |
addConnectionPool(java.lang.String poolName,
TConnectionPoolDescriptor descriptor,
java.util.Locale locale)
Adds a connection pool to the list of managed pools.
|
void |
addConnectionPools(java.io.InputStream inputStream)
Deprecated.
Please use the following methods instead:
|
TConnection |
getConnection(java.lang.String poolName)
Gets a pooled connection for the given pool.
|
static TConnectionPoolManager |
getInstance()
Gets the singleton TConnectionPoolManager instance.
|
java.util.Iterator<java.lang.String> |
getPoolNames()
Gets the pool names of all managed pools as an iterator.
|
TConnectionPoolStatistics |
getStatistics(java.lang.String poolName)
Delivers statistical information on a connection pool
|
boolean |
hasPool(java.lang.String poolName)
Indicates if the pool with the given name exist.
|
boolean |
isEmpty()
Indicates if the pool manager contains any pools or none.
|
void |
release()
Release all pools from the pool manager.
|
void |
release(java.lang.String poolName)
Release the specified pool from the pool manager.
|
java.lang.String |
toString()
Writes the statistics for all managed pools into a String.
|
public static TConnectionPoolManager getInstance() throws TConnectionNotAvailableException
TConnectionNotAvailableException
public TConnection getConnection(java.lang.String poolName) throws TConnectionNotAvailableException
poolName
- a pool name managed by the connection pool manager.TConnectionNotAvailableException
- if no more connection is available from the specified pool.public void release()
public void release(java.lang.String poolName)
poolName
- the name of the pool to release.public java.util.Iterator<java.lang.String> getPoolNames()
public boolean hasPool(java.lang.String poolName)
public TConnectionPoolStatistics getStatistics(java.lang.String poolName)
public boolean addConnectionPool(java.lang.String poolName, TConnectionPoolDescriptor descriptor) throws TServerNotAvailableException
poolName
- the name of the pool (identification)descriptor
- a TConnectionPoolDescriptor object describing the properties of the pool
and its connections.TServerNotAvailableException
public boolean addConnectionPool(java.lang.String poolName, java.lang.String databaseURI, java.lang.String user, java.lang.String password, int maxConnections, int initConnections, int timeOut) throws TServerNotAvailableException
poolName
- the name of the pool (identification)databaseURI
- the database URIuser
- the user identificationpassword
- the passwordmaxConnections
- the number of maximum connections this pool can handleinitConnections
- the initial number of connections this pool can handletimeOut
- this pools timeout value (seconds) the manager waits for connections
to be retrieved from the pool.TServerNotAvailableException
public boolean addConnectionPool(java.lang.String poolName, java.lang.String databaseURI, java.lang.String domain, java.lang.String user, java.lang.String password, int maxConnections, int initConnections, int timeOut) throws TServerNotAvailableException
poolName
- the name of the pool (identification)databaseURI
- the database URIdomain
- the domain identificationuser
- the user identificationpassword
- the passwordmaxConnections
- the number of maximum connections this pool can handleinitConnections
- the initial number of connections this pool can handletimeOut
- this pools timeout value (seconds) the manager waits for connections
to be retrieved from the pool.TServerNotAvailableException
public void addConnectionPools(java.io.InputStream inputStream) throws TConnectionNotAvailableException
inputStream
- the pool definition xml stream.TConnectionNotAvailableException
public boolean addConnectionPool(java.lang.String poolName, TConnectionPoolDescriptor descriptor, java.util.Locale locale) throws TServerNotAvailableException
poolName
- the name of the pool (identification)descriptor
- a TConnectionPoolDescriptor object describing the properties of the pool
and its connections.TServerNotAvailableException
public boolean addConnectionPool(java.lang.String poolName, java.lang.String databaseURI, java.lang.String user, java.lang.String password, int maxConnections, int initConnections, int timeOut, java.util.Locale locale) throws TServerNotAvailableException
poolName
- the name of the pool (identification)databaseURI
- the database URIuser
- the user identificationpassword
- the passwordmaxConnections
- the number of maximum connections this pool can handleinitConnections
- the initial number of connections this pool can handletimeOut
- this pools timeout value (seconds) the manager waits for connections
to be retrieved from the pool.TServerNotAvailableException
public boolean addConnectionPool(java.lang.String poolName, java.lang.String databaseURI, java.lang.String domain, java.lang.String user, java.lang.String password, int maxConnections, int initConnections, int timeOut, java.util.Locale locale) throws TServerNotAvailableException
poolName
- the name of the pool (identification)databaseURI
- the database URIdomain
- the domain identificationuser
- the user identificationpassword
- the passwordmaxConnections
- the number of maximum connections this pool can handleinitConnections
- the initial number of connections this pool can handletimeOut
- this pools timeout value (seconds) the manager waits for connections
to be retrieved from the pool.TServerNotAvailableException
public boolean isEmpty()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright (c) 2017 Software AG. All Rights Reserved.