public class DefaultConnectionPool extends Object implements ConnectionPool
Constructor and Description |
---|
DefaultConnectionPool() |
Modifier and Type | Method and Description |
---|---|
protected void |
finalize() |
void |
freeUnused()
Go through the connection pool and release any connections
that are not InUse;
|
Connection |
getConnection()
Retrive a database connection from the pool
|
boolean |
hasActiveConnections()
Is our ConnectionPool have any connections that are still in Use ??
|
void |
initializePool() |
boolean |
isEnabled()
Return our current Active state
|
void |
releaseConnection(Connection con)
Return a connection to the pool, the connection may be closed if the
pool is inactive or has exceeded the max number of free connections
|
void |
releaseConnectionOnError(Connection con)
Provide a mechinism to return a connection to the pool on Error.
|
void |
setDriver(String d)
Set the driver call to be used to create connections
|
void |
setMinConnections(int n)
Override the current number of connections to keep in the pool.
|
void |
setPassword(String p)
Set the password in the property set.
|
void |
setPoolEnabled(boolean flag)
The Pool can be Enabled and Disabled.
|
void |
setProtocol(Properties p)
The Protocol string is used to pass in other connection
properties.
|
void |
setURL(String url)
Set the url used to connect to the database
|
void |
setUser(String u)
Set the user name in the property set
|
boolean |
testConnection()
Try to aquire a new connection, if it succeeds then return
true, else return false.
|
public boolean isEnabled()
isEnabled
in interface ConnectionPool
public void setDriver(String d)
setDriver
in interface ConnectionPool
d
- public void setURL(String url)
setURL
in interface ConnectionPool
url
- public void freeUnused()
freeUnused
in interface ConnectionPool
public boolean hasActiveConnections()
hasActiveConnections
in interface ConnectionPool
public void setPassword(String p)
setPassword
in interface ConnectionPool
p
- public void setUser(String u)
setUser
in interface ConnectionPool
u
- public void setProtocol(Properties p)
setProtocol
in interface ConnectionPool
p
- public void setMinConnections(int n)
setMinConnections
in interface ConnectionPool
n
- public boolean testConnection()
testConnection
in interface ConnectionPool
public Connection getConnection() throws IllegalArgumentException, SQLException
ConnectionPool
getConnection
in interface ConnectionPool
SQLException
IllegalArgumentException
public void releaseConnection(Connection con) throws SQLException
ConnectionPool
releaseConnection
in interface ConnectionPool
con
- SQLException
public void releaseConnectionOnError(Connection con) throws SQLException
ConnectionPool
releaseConnectionOnError
in interface ConnectionPool
con
- SQLException
public void initializePool() throws IllegalArgumentException, SQLException
IllegalArgumentException
SQLException
protected void finalize() throws Throwable
public void setPoolEnabled(boolean flag)
setPoolEnabled
in interface ConnectionPool
flag
- Control the Connection Pool.
If it is enabled then Connections will actuall be held
around. If disabled then all unused connections will be instantly
closed and as connections are released they are closed and removed
from the pool.Copyright © 2012 JBoss by Red Hat. All Rights Reserved.