public class JNDIConnectionSource extends ConnectionSourceBase
ConnectionSource that obtains a DataSource from a
JNDI provider and uses it to obtain a Connection. It is
primarily designed to be used inside of J2EE application servers or
application server clients, assuming the application server supports remote
access of DataSources. In this way one can take advantage
of connection pooling and whatever other goodies the application server
provides.
For more information about this component, please refer to the online manual at http://logback.qos.ch/manual/appenders.html#DBAppender
| Modifier and Type | Field and Description |
|---|---|
private javax.sql.DataSource |
dataSource |
private java.lang.String |
jndiLocation |
context| Constructor and Description |
|---|
JNDIConnectionSource() |
| Modifier and Type | Method and Description |
|---|---|
java.sql.Connection |
getConnection()
Obtain a
Connection for use. |
java.lang.String |
getJndiLocation()
Returns the jndiLocation.
|
private javax.sql.DataSource |
lookupDataSource() |
void |
setJndiLocation(java.lang.String jndiLocation)
Sets the jndiLocation.
|
void |
start() |
discoverConnectionProperties, getPassword, getSQLDialectCode, getUser, isStarted, setPassword, setUser, stop, supportsBatchUpdates, supportsGetGeneratedKeysaddError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextprivate java.lang.String jndiLocation
private javax.sql.DataSource dataSource
public void start()
start in interface LifeCyclestart in class ConnectionSourceBasepublic java.sql.Connection getConnection()
throws java.sql.SQLException
ConnectionSourceConnection for use. The client is
responsible for closing the Connection when it is no
longer required.java.sql.SQLException - if a Connection could not be
obtainedpublic java.lang.String getJndiLocation()
public void setJndiLocation(java.lang.String jndiLocation)
jndiLocation - The jndiLocation to setprivate javax.sql.DataSource lookupDataSource()
throws javax.naming.NamingException,
java.sql.SQLException
javax.naming.NamingExceptionjava.sql.SQLException