|
Log4j 1.3alpha-6 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.log4j.spi.ComponentBase | +--org.apache.log4j.db.ConnectionSourceSkeleton | +--org.apache.log4j.db.JNDIConnectionSource
The 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 DataSource
s. In this way one can take
advantage of connection pooling and whatever other goodies the application
server provides.
Sample configuration:
<connectionSource class="org.apache.log4j.jdbc.JNDIConnectionSource"> <param name="jndiLocation" value="jdbc/MySQLDS" /> </connectionSource>
Sample configuration (with username and password):
<connectionSource class="org.apache.log4j.jdbc.JNDIConnectionSource"> <param name="jndiLocation" value="jdbc/MySQLDS" /> <param name="username" value="myUser" /> <param name="password" value="myPassword" /> </connectionSource>
Note that this class will obtain an InitialContext
using the no-argument constructor. This will usually work when executing
within a J2EE environment. When outside the J2EE environment, make sure
that you provide a jndi.properties file as described by your JNDI
provider's documentation.
Field Summary |
Fields inherited from class org.apache.log4j.db.ConnectionSourceSkeleton |
dialectCode, password, supportsBatchUpdates, supportsGetGeneratedKeys, user |
Fields inherited from class org.apache.log4j.spi.ComponentBase |
repository |
Fields inherited from interface org.apache.log4j.db.ConnectionSource |
HSQL_DIALECT, MSSQL_DIALECT, MYSQL_DIALECT, ORACLE_DIALECT, POSTGRES_DIALECT, UNKNOWN_DIALECT |
Constructor Summary | |
JNDIConnectionSource()
|
Method Summary | |
void |
activateOptions()
Activate the options that were previously set with calls to option setters. |
java.sql.Connection |
getConnection()
Obtain a Connection for use. |
java.lang.String |
getJndiLocation()
Returns the jndiLocation. |
int |
getSQLDialectCode()
Get the SQL dialect that should be used for this connection. |
void |
setJndiLocation(java.lang.String jndiLocation)
Sets the jndiLocation. |
void |
setPassword(java.lang.String password)
Sets the password. |
Methods inherited from class org.apache.log4j.db.ConnectionSourceSkeleton |
discoverConnnectionProperties, getPassword, getUser, setUser, supportsBatchUpdates, supportsGetGeneratedKeys |
Methods inherited from class org.apache.log4j.spi.ComponentBase |
getLogger, setLoggerRepository |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.apache.log4j.spi.Component |
setLoggerRepository |
Constructor Detail |
public JNDIConnectionSource()
Method Detail |
public void activateOptions()
OptionHandler
This allows to defer activiation of the options until all options have been set. This is required for components which have related options that remain ambigous until all are set.
For example, the FileAppender has the File
and Append
options both of
which are ambigous until the other is also set.
OptionHandler.activateOptions()
public java.sql.Connection getConnection() throws java.sql.SQLException
ConnectionSource
Connection
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
obtainedConnectionSource.getConnection()
public java.lang.String getJndiLocation()
public void setJndiLocation(java.lang.String jndiLocation)
jndiLocation
- The jndiLocation to setpublic void setPassword(java.lang.String password)
setPassword
in class ConnectionSourceSkeleton
password
- The password to setpublic int getSQLDialectCode()
ConnectionSource
getSQLDialectCode
in interface ConnectionSource
getSQLDialectCode
in class ConnectionSourceSkeleton
|
Log4j 1.3alpha-6 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |