|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.xalan.lib.sql.JNDIConnectionPool
public class JNDIConnectionPool
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.
Field Summary | |
---|---|
private java.lang.reflect.Method |
getConnection
|
private java.lang.reflect.Method |
getConnectionWithArgs
To maintain Java 1.3 compatibility, we need to work with the DataSource class through Reflection. |
protected java.lang.Object |
jdbcSource
Reference to the datasource |
protected java.lang.String |
jndiPath
The unique jndi path for this datasource. |
protected java.lang.String |
pwd
Password for protected datasources. |
protected java.lang.String |
user
User name for protected datasources. |
Constructor Summary | |
---|---|
JNDIConnectionPool()
Use of the default constructor requires the jndi path to be set via setJndiPath(). |
|
JNDIConnectionPool(java.lang.String jndiDatasourcePath)
Creates a connection pool with a specified JNDI path. |
Method Summary | |
---|---|
protected void |
findDatasource()
Internal method used to look up the datasource. |
void |
freeUnused()
Intended to release unused connections from the pool. |
java.sql.Connection |
getConnection()
Returns a connection from the JDNI DataSource found at the JNDI Datasource path. |
java.lang.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(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 connections |
void |
releaseConnectionOnError(java.sql.Connection con)
Provide a mechinism to return a connection to the pool on Error. |
void |
setDriver(java.lang.String d)
Not implemented and will throw an Error if called. |
void |
setJndiPath(java.lang.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(java.lang.String p)
Sets the password for the connection. |
void |
setPoolEnabled(boolean flag)
Releases the reference to the jndi datasource. |
void |
setProtocol(java.util.Properties p)
Ignored in this implementation b/c the pooling is determined by the jndi dataosource. |
void |
setURL(java.lang.String url)
Not implemented and will throw an Error if called. |
void |
setUser(java.lang.String u)
Sets the user name for the connection. |
boolean |
testConnection()
A simple test to see if the jndi datasource exists. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected java.lang.Object jdbcSource
private java.lang.reflect.Method getConnectionWithArgs
private java.lang.reflect.Method getConnection
protected java.lang.String jndiPath
protected java.lang.String user
protected java.lang.String pwd
Constructor Detail |
---|
public JNDIConnectionPool()
public JNDIConnectionPool(java.lang.String jndiDatasourcePath)
jndiDatasourcePath
- Complete path to the JNDI datasourceMethod Detail |
---|
public void setJndiPath(java.lang.String jndiPath)
jndiPath
- public java.lang.String getJndiPath()
jndiPath
- public boolean isEnabled()
isEnabled
in interface ConnectionPool
public void setDriver(java.lang.String d)
setDriver
in interface ConnectionPool
d
- public void setURL(java.lang.String url)
setURL
in interface ConnectionPool
d
- public void freeUnused()
freeUnused
in interface ConnectionPool
public boolean hasActiveConnections()
hasActiveConnections
in interface ConnectionPool
public void setPassword(java.lang.String p)
setPassword
in interface ConnectionPool
p
- the passwordpublic void setUser(java.lang.String u)
setUser
in interface ConnectionPool
u
- the user namepublic java.sql.Connection getConnection() throws java.sql.SQLException
getConnection
in interface ConnectionPool
java.sql.SQLException
protected void findDatasource() throws javax.naming.NamingException
javax.naming.NamingException
public void releaseConnection(java.sql.Connection con) throws java.sql.SQLException
ConnectionPool
releaseConnection
in interface ConnectionPool
java.sql.SQLException
public void releaseConnectionOnError(java.sql.Connection con) throws java.sql.SQLException
ConnectionPool
releaseConnectionOnError
in interface ConnectionPool
java.sql.SQLException
public void setPoolEnabled(boolean flag)
setPoolEnabled
in interface ConnectionPool
flag
- If false, the reference to the datasource is released.public void setProtocol(java.util.Properties p)
setProtocol
in interface ConnectionPool
p
- public void setMinConnections(int n)
setMinConnections
in interface ConnectionPool
n
- public boolean testConnection()
testConnection
in interface ConnectionPool
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |