Package org.apache.xalan.lib.sql
Class DefaultConnectionPool
java.lang.Object
org.apache.xalan.lib.sql.DefaultConnectionPool
- All Implemented Interfaces:
ConnectionPool
For internal connectiones, i.e. Connection information supplies in the
Stylesheet. The Default Connection Pool will be used.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Go through the connection pool and release any connections that are not InUse;Retrive a database connection from the poolboolean
Is our ConnectionPool have any connections that are still in Use ??void
boolean
Return our current Active statevoid
Return a connection to the pool, the connection may be closed if the pool is inactive or has exceeded the max number of free connectionsvoid
Provide a mechinism to return a connection to the pool on Error.void
Set the driver call to be used to create connectionsvoid
setMinConnections
(int n) Override the current number of connections to keep in the pool.void
Set the password in the property set.void
setPoolEnabled
(boolean flag) The Pool can be Enabled and Disabled.void
The Protocol string is used to pass in other connection properties.void
Set the url used to connect to the databasevoid
Set the user name in the property setboolean
Try to aquire a new connection, if it succeeds then return true, else return false.
-
Constructor Details
-
DefaultConnectionPool
public DefaultConnectionPool()
-
-
Method Details
-
isEnabled
public boolean isEnabled()Return our current Active state- Specified by:
isEnabled
in interfaceConnectionPool
-
setDriver
Set the driver call to be used to create connections- Specified by:
setDriver
in interfaceConnectionPool
- Parameters:
d
-
-
setURL
Set the url used to connect to the database- Specified by:
setURL
in interfaceConnectionPool
- Parameters:
url
-
-
freeUnused
public void freeUnused()Go through the connection pool and release any connections that are not InUse;- Specified by:
freeUnused
in interfaceConnectionPool
-
hasActiveConnections
public boolean hasActiveConnections()Is our ConnectionPool have any connections that are still in Use ??- Specified by:
hasActiveConnections
in interfaceConnectionPool
-
setPassword
Set the password in the property set.- Specified by:
setPassword
in interfaceConnectionPool
- Parameters:
p
-
-
setUser
Set the user name in the property set- Specified by:
setUser
in interfaceConnectionPool
- Parameters:
u
-
-
setProtocol
The Protocol string is used to pass in other connection properties. A properties file is a general purpose container- Specified by:
setProtocol
in interfaceConnectionPool
- Parameters:
p
-
-
setMinConnections
public void setMinConnections(int n) Override the current number of connections to keep in the pool. This setting will only have effect on a new pool or when a new connection is requested and there is less connections that this setting.- Specified by:
setMinConnections
in interfaceConnectionPool
- Parameters:
n
-
-
testConnection
public boolean testConnection()Try to aquire a new connection, if it succeeds then return true, else return false. Note: This method will cause the connection pool to be built.- Specified by:
testConnection
in interfaceConnectionPool
-
getConnection
Description copied from interface:ConnectionPool
Retrive a database connection from the pool- Specified by:
getConnection
in interfaceConnectionPool
- Returns:
- Connection
- Throws:
SQLException
IllegalArgumentException
-
releaseConnection
Description copied from interface:ConnectionPool
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- Specified by:
releaseConnection
in interfaceConnectionPool
- Parameters:
con
-- Throws:
SQLException
-
releaseConnectionOnError
Description copied from interface:ConnectionPool
Provide a mechinism to return a connection to the pool on Error. A good default behaviour is to close this connection and build a new one to replace it. Some JDBC impl's won't allow you to reuse a connection after an error occurs.- Specified by:
releaseConnectionOnError
in interfaceConnectionPool
- Parameters:
con
-- Throws:
SQLException
-
initializePool
- Throws:
IllegalArgumentException
SQLException
-
setPoolEnabled
public void setPoolEnabled(boolean flag) The Pool can be Enabled and Disabled. Disabling the pool closes all the outstanding Unused connections and any new connections will be closed upon release.- Specified by:
setPoolEnabled
in interfaceConnectionPool
- Parameters:
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.
-