public class JNDIConnectionPool extends Object implements ConnectionPool
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.Modifier and Type | Field and Description |
---|---|
protected Object |
jdbcSource
Reference to the datasource
|
protected String |
jndiPath
The unique jndi path for this datasource.
|
protected String |
pwd
Password for protected datasources.
|
protected String |
user
User name for protected datasources.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
findDatasource()
Internal method used to look up the datasource.
|
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)
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)
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.
|
protected Object jdbcSource
protected String jndiPath
protected String user
protected String pwd
public JNDIConnectionPool()
public JNDIConnectionPool(String jndiDatasourcePath)
jndiDatasourcePath
- Complete path to the JNDI datasourcepublic void setJndiPath(String jndiPath)
jndiPath
- public String getJndiPath()
jndiPath
- 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
d
- public void freeUnused()
freeUnused
in interface ConnectionPool
public boolean hasActiveConnections()
hasActiveConnections
in interface ConnectionPool
public void setPassword(String p)
setPassword
in interface ConnectionPool
p
- the passwordpublic void setUser(String u)
setUser
in interface ConnectionPool
u
- the user namepublic Connection getConnection() throws SQLException
getConnection
in interface ConnectionPool
SQLException
protected void findDatasource() throws NamingException
NamingException
public void releaseConnection(Connection con) throws SQLException
ConnectionPool
releaseConnection
in interface ConnectionPool
SQLException
public void releaseConnectionOnError(Connection con) throws SQLException
ConnectionPool
releaseConnectionOnError
in interface ConnectionPool
SQLException
public void setPoolEnabled(boolean flag)
setPoolEnabled
in interface ConnectionPool
flag
- If false, the reference to the datasource is released.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
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.