|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.objectweb.cjdbc.controller.connection.AbstractConnectionManager
org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager
org.objectweb.cjdbc.controller.connection.VariablePoolConnectionManager
This connection manager provides connection pooling with a dynamically adjustable pool size.
If the maximum number of active connections is not reached, the
getConnection()
method creates a connection. Else,
the execution is blocked until a connection is freed or the timeout
waitTimeout
expires.
Idle connections in the pool are removed after the timeout
idleTimeout
if the minimum pool size minPoolSize
has not
been reached.
Nested Class Summary | |
protected class |
VariablePoolConnectionManager.RemoveIdleConnectionsThread
Allows to remove idle free connections after the idleTimeout
timeout. |
Field Summary | |
static int |
DEFAULT_IDLE_TIMEOUT
Default idle timeout in milliseconds: default is 0 and means that once allocated, connections are never released. |
static int |
DEFAULT_MAX_POOL_SIZE
Default maximum pool size: default is 0 and means no limit. |
static int |
DEFAULT_WAIT_TIMEOUT
Default wait timeout in milliseconds: the default is 0 and means no timeout: waits until one connection is freed. |
private int |
idleTimeout
Time a connection can stay idle before begin released (removed from the pool) in milliseconds (0 means forever) |
private int |
initPoolSize
Initial pool size to be initialized at startup. |
private int |
maxPoolSize
Maximum pool size. |
private int |
minPoolSize
Minimum pool size. |
private java.util.Stack |
releaseTimes
Stores the time on which connections have been released. |
private VariablePoolConnectionManager.RemoveIdleConnectionsThread |
removeIdleConnectionsThread
Allow to remove idle connections in the pool. |
private int |
waitTimeout
Maximum time to wait for a connection in milliseconds. |
Fields inherited from class org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager |
activeConnections, freeConnections, poolSize |
Fields inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager |
backendName, backendUrl, initialized, logger, rLogin, rPassword |
Constructor Summary | |
VariablePoolConnectionManager(java.lang.String backendUrl,
java.lang.String backendName,
java.lang.String rLogin,
java.lang.String rPassword,
int minPoolSize,
int maxPoolSize,
int idleTimeout,
int waitTimeout)
Creates a new VariablePoolConnectionManager instance with the
default minPoolSize (initial pool size to be initialized at
startup). |
|
VariablePoolConnectionManager(java.lang.String backendUrl,
java.lang.String backendName,
java.lang.String rLogin,
java.lang.String rPassword,
int initPoolSize,
int minPoolSize,
int maxPoolSize,
int idleTimeout,
int waitTimeout)
Creates a new VariablePoolConnectionManager instance. |
Method Summary | |
void |
finalizeConnections()
Releases all the connections to the database. |
java.sql.Connection |
getConnection()
Gets a connection from the pool. |
int |
getIdleTimeout()
Gets the idle timeout. |
java.lang.String |
getInformation()
Gets information about this connection manager |
int |
getMaxPoolSize()
Gets the max pool size. |
int |
getMinPoolSize()
Gets the min pool size. |
int |
getWaitTimeout()
Gets the wait timeout. |
java.lang.String |
getXmlInformation()
Gets xml formatted information on this connection manager |
void |
initializeConnections()
Initializes the connection(s) to the database. |
void |
releaseConnection(java.sql.Connection c)
Releases a connection and puts it back to the pool. |
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractPoolConnectionManager |
initializeConnections |
Methods inherited from class org.objectweb.cjdbc.controller.connection.AbstractConnectionManager |
finalize, getConnection, getLogin, getPassword, isInitialized, releaseConnection, retrieveConnection, setLogin, setPassword |
Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int DEFAULT_MAX_POOL_SIZE
public static final int DEFAULT_IDLE_TIMEOUT
public static final int DEFAULT_WAIT_TIMEOUT
private int initPoolSize
private int minPoolSize
private int maxPoolSize
private int idleTimeout
private int waitTimeout
private java.util.Stack releaseTimes
private VariablePoolConnectionManager.RemoveIdleConnectionsThread removeIdleConnectionsThread
Constructor Detail |
public VariablePoolConnectionManager(java.lang.String backendUrl, java.lang.String backendName, java.lang.String rLogin, java.lang.String rPassword, int minPoolSize, int maxPoolSize, int idleTimeout, int waitTimeout)
VariablePoolConnectionManager
instance with the
default minPoolSize
(initial pool size to be initialized at
startup).
backendUrl
- URL of the DatabaseBackend
owning this
connection managerbackendName
- name of the DatabaseBackend
owning this
connection managerrLogin
- backend connection login to be used by this connection
managerrPassword
- backend connection password to be used by this connection
managerminPoolSize
- minimum pool size.maxPoolSize
- maximum pool size. 0 means no limit.idleTimeout
- time a connection can stay idle before begin released
(removed from the pool) in seconds. 0 means no timeout: once allocated,
connections are never released.waitTimeout
- maximum time to wait for a connection in seconds. 0
means no timeout: waits until one connection is freed.public VariablePoolConnectionManager(java.lang.String backendUrl, java.lang.String backendName, java.lang.String rLogin, java.lang.String rPassword, int initPoolSize, int minPoolSize, int maxPoolSize, int idleTimeout, int waitTimeout)
VariablePoolConnectionManager
instance.
backendUrl
- URL of the DatabaseBackend
owning this
connection managerbackendName
- name of the DatabaseBackend
owning this
connection managerrLogin
- backend connection login to be used by this connection
managerrPassword
- backend connection password to be used by this connection
managerinitPoolSize
- initial pool size to be intialized at startupminPoolSize
- minimum pool size.maxPoolSize
- maximum pool size. 0 means no limit.idleTimeout
- time a connection can stay idle before begin released
(removed from the pool) in seconds. 0 means no timeout: once allocated,
connections are never released.waitTimeout
- maximum time to wait for a connection in seconds. 0
means no timeout: waits until one connection is freed.Method Detail |
public int getMaxPoolSize()
int
value.public int getMinPoolSize()
int
value.public int getIdleTimeout()
int
value.idleTimeout
public int getWaitTimeout()
int
value.waitTimeout
public void initializeConnections() throws java.sql.SQLException
AbstractConnectionManager
initializeConnections
in class AbstractPoolConnectionManager
java.sql.SQLException
AbstractPoolConnectionManager.initializeConnections()
public void finalizeConnections() throws java.sql.SQLException
AbstractConnectionManager
finalizeConnections
in class AbstractPoolConnectionManager
java.sql.SQLException
AbstractConnectionManager.finalizeConnections()
public java.sql.Connection getConnection()
If the current number of active connections is lower than the maxminum
pool size maxPoolSize
, a new connection is created. If the
creation fails, this method waits for a connection to be freed.
If the maximum number of active connections is reached, this methods
blocks until a connection is freed or the timeout waitTimeout
expires.
getConnection
in class AbstractConnectionManager
null
if the timeout has
expired.AbstractConnectionManager.getConnection()
public void releaseConnection(java.sql.Connection c)
AbstractPoolConnectionManager
releaseConnection
in class AbstractPoolConnectionManager
c
- the connection to release.AbstractConnectionManager.releaseConnection(Connection)
public java.lang.String getXmlInformation()
AbstractConnectionManager
getXmlInformation
in class AbstractConnectionManager
AbstractConnectionManager.getInformation()
public java.lang.String getInformation()
AbstractConnectionManager
getInformation
in class AbstractConnectionManager
String
value containing information.AbstractConnectionManager.getInformation()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |