org.apache.xalan.lib.sql
Class JNDIConnectionPool
java.lang.Object
org.apache.xalan.lib.sql.JNDIConnectionPool
- ConnectionPool
public class JNDIConnectionPool
extends java.lang.Object
A Connection Pool that wraps a JDBC datasource to provide connections.
An instance of this class is created by XConnection
when it
attempts to resolves a ConnectionPool
name as a JNDI data source.
Most methods in this implementation do nothing since configuration is handled
by the underlying JDBC datasource. Users should always call
XConnection.close()
from their stylsheet to explicitely close
their connection. However, since there is no way to enforce this
(Yikes!), it is recommended that a relatively short datasource timeout
be used to prevent dangling connections.
JNDIConnectionPool() - Use of the default constructor requires the jndi path to be set via
setJndiPath().
|
JNDIConnectionPool(String jndiDatasourcePath) - Creates a connection pool with a specified JNDI path.
|
void | freeUnused() - Intended to release unused connections from the pool.
|
Connection | getConnection() - Returns a connection from the JDNI DataSource found at the JNDI Datasource
path.
|
String | getJndiPath() - Returns the path for the jndi datasource
|
boolean | hasActiveConnections() - Always returns false, indicating that this wrapper has no idea of what
connections the underlying JNDI source is maintaining.
|
boolean | isEnabled() - Always returns true.
|
void | releaseConnection(Connection con)
|
void | releaseConnectionOnError(Connection con)
|
void | setDriver(String d) - Not implemented and will throw an Error if called.
|
void | setJndiPath(String jndiPath) - Sets the path for the jndi datasource
|
void | setMinConnections(int n) - Ignored in this implementation b/c the pooling is determined by the jndi dataosource.
|
void | setPassword(String p) - Sets the password for the connection.
|
void | setPoolEnabled(boolean flag) - Releases the reference to the jndi datasource.
|
void | setProtocol(Properties p) - Ignored in this implementation b/c the pooling is determined by the jndi dataosource.
|
void | setURL(String url) - Not implemented and will throw an Error if called.
|
void | setUser(String u) - Sets the user name for the connection.
|
boolean | testConnection() - A simple test to see if the jndi datasource exists.
|
JNDIConnectionPool
public JNDIConnectionPool()
Use of the default constructor requires the jndi path to be set via
setJndiPath().
JNDIConnectionPool
public JNDIConnectionPool(String jndiDatasourcePath)
Creates a connection pool with a specified JNDI path.
jndiDatasourcePath
- Complete path to the JNDI datasource
freeUnused
public void freeUnused()
Intended to release unused connections from the pool.
Does nothing in this implementation.
- freeUnused in interface ConnectionPool
getConnection
public Connection getConnection()
throws SQLException
Returns a connection from the JDNI DataSource found at the JNDI Datasource
path.
- getConnection in interface ConnectionPool
getJndiPath
public String getJndiPath()
Returns the path for the jndi datasource
hasActiveConnections
public boolean hasActiveConnections()
Always returns false, indicating that this wrapper has no idea of what
connections the underlying JNDI source is maintaining.
- hasActiveConnections in interface ConnectionPool
isEnabled
public boolean isEnabled()
Always returns true.
This method was intended to indicate if the pool was enabled, however, in
this implementation that is not relavant.
- isEnabled in interface ConnectionPool
setDriver
public void setDriver(String d)
Not implemented and will throw an Error if called.
Connection configuration is handled by the underlying JNDI DataSource.
- setDriver in interface ConnectionPool
setJndiPath
public void setJndiPath(String jndiPath)
Sets the path for the jndi datasource
setMinConnections
public void setMinConnections(int n)
Ignored in this implementation b/c the pooling is determined by the jndi dataosource.
- setMinConnections in interface ConnectionPool
setPassword
public void setPassword(String p)
Sets the password for the connection.
If the jndi datasource does not require a password (which is typical),
this can be left null.
- setPassword in interface ConnectionPool
setPoolEnabled
public void setPoolEnabled(boolean flag)
Releases the reference to the jndi datasource.
The original intention of this method was to actually turn the pool *off*.
Since we are not managing the pool, we simply release our reference to
the datasource. Future calls to the getConnection will simply recreate
the datasource.
- setPoolEnabled in interface ConnectionPool
flag
- If false, the reference to the datasource is released.
setProtocol
public void setProtocol(Properties p)
Ignored in this implementation b/c the pooling is determined by the jndi dataosource.
- setProtocol in interface ConnectionPool
setURL
public void setURL(String url)
Not implemented and will throw an Error if called.
Connection configuration is handled by the underlying JNDI DataSource.
- setURL in interface ConnectionPool
setUser
public void setUser(String u)
Sets the user name for the connection.
If the jndi datasource does not require a user name (which is typical),
this can be left null.
- setUser in interface ConnectionPool
testConnection
public boolean testConnection()
A simple test to see if the jndi datasource exists.
Note that this test does not ensure that the datasource will return valid
connections.
- testConnection in interface ConnectionPool
Copyright B) 2006 Apache XML Project. All Rights Reserved.