Package org.apache.xalan.lib.sql
Class DefaultConnectionPool
- java.lang.Object
-
- org.apache.xalan.lib.sql.DefaultConnectionPool
-
- All Implemented Interfaces:
ConnectionPool
public class DefaultConnectionPool extends java.lang.Object implements ConnectionPool
For internal connectiones, i.e. Connection information supplies in the Stylesheet. The Default Connection Pool will be used.
-
-
Constructor Summary
Constructors Constructor Description DefaultConnectionPool()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfreeUnused()Go through the connection pool and release any connections that are not InUse;java.sql.ConnectiongetConnection()Retrive a database connection from the poolbooleanhasActiveConnections()Is our ConnectionPool have any connections that are still in Use ??voidinitializePool()booleanisEnabled()Return our current Active statevoidreleaseConnection(java.sql.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 connectionsvoidreleaseConnectionOnError(java.sql.Connection con)Provide a mechinism to return a connection to the pool on Error.voidsetDriver(java.lang.String d)Set the driver call to be used to create connectionsvoidsetMinConnections(int n)Override the current number of connections to keep in the pool.voidsetPassword(java.lang.String p)Set the password in the property set.voidsetPoolEnabled(boolean flag)The Pool can be Enabled and Disabled.voidsetProtocol(java.util.Properties p)The Protocol string is used to pass in other connection properties.voidsetURL(java.lang.String url)Set the url used to connect to the databasevoidsetUser(java.lang.String u)Set the user name in the property setbooleantestConnection()Try to aquire a new connection, if it succeeds then return true, else return false.
-
-
-
Method Detail
-
isEnabled
public boolean isEnabled()
Return our current Active state- Specified by:
isEnabledin interfaceConnectionPool
-
setDriver
public void setDriver(java.lang.String d)
Set the driver call to be used to create connections- Specified by:
setDriverin interfaceConnectionPool- Parameters:
d-
-
setURL
public void setURL(java.lang.String url)
Set the url used to connect to the database- Specified by:
setURLin interfaceConnectionPool- Parameters:
url-
-
freeUnused
public void freeUnused()
Go through the connection pool and release any connections that are not InUse;- Specified by:
freeUnusedin interfaceConnectionPool
-
hasActiveConnections
public boolean hasActiveConnections()
Is our ConnectionPool have any connections that are still in Use ??- Specified by:
hasActiveConnectionsin interfaceConnectionPool
-
setPassword
public void setPassword(java.lang.String p)
Set the password in the property set.- Specified by:
setPasswordin interfaceConnectionPool- Parameters:
p-
-
setUser
public void setUser(java.lang.String u)
Set the user name in the property set- Specified by:
setUserin interfaceConnectionPool- Parameters:
u-
-
setProtocol
public void setProtocol(java.util.Properties p)
The Protocol string is used to pass in other connection properties. A properties file is a general purpose container- Specified by:
setProtocolin 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:
setMinConnectionsin 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:
testConnectionin interfaceConnectionPool
-
getConnection
public java.sql.Connection getConnection() throws java.lang.IllegalArgumentException, java.sql.SQLExceptionDescription copied from interface:ConnectionPoolRetrive a database connection from the pool- Specified by:
getConnectionin interfaceConnectionPool- Returns:
- Connection
- Throws:
java.sql.SQLExceptionjava.lang.IllegalArgumentException
-
releaseConnection
public void releaseConnection(java.sql.Connection con) throws java.sql.SQLExceptionDescription copied from interface:ConnectionPoolReturn 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:
releaseConnectionin interfaceConnectionPool- Parameters:
con-- Throws:
java.sql.SQLException
-
releaseConnectionOnError
public void releaseConnectionOnError(java.sql.Connection con) throws java.sql.SQLExceptionDescription copied from interface:ConnectionPoolProvide 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:
releaseConnectionOnErrorin interfaceConnectionPool- Parameters:
con-- Throws:
java.sql.SQLException
-
initializePool
public void initializePool() throws java.lang.IllegalArgumentException, java.sql.SQLException- Throws:
java.lang.IllegalArgumentExceptionjava.sql.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:
setPoolEnabledin 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.
-
-