org.apache.log4j.db
クラス JNDIConnectionSource

java.lang.Object
  上位を拡張 org.apache.log4j.spi.ComponentBase
      上位を拡張 org.apache.log4j.db.ConnectionSourceSkeleton
          上位を拡張 org.apache.log4j.db.JNDIConnectionSource
すべての実装されたインタフェース:
ConnectionSource, org.apache.log4j.spi.Component, org.apache.log4j.spi.OptionHandler

public class JNDIConnectionSource
extends ConnectionSourceSkeleton

The JNDIConnectionSource is an implementation of 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.

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.

作成者:
Ray DeCampo

フィールドの概要
 
クラス org.apache.log4j.spi.ComponentBase から継承されたフィールド
repository
 
インタフェース org.apache.log4j.db.ConnectionSource から継承されたフィールド
HSQL_DIALECT, MSSQL_DIALECT, MYSQL_DIALECT, ORACLE_DIALECT, POSTGRES_DIALECT, UNKNOWN_DIALECT
 
コンストラクタの概要
JNDIConnectionSource()
           
 
メソッドの概要
 void activateOptions()
           
 java.sql.Connection getConnection()
          Obtain a Connection for use.
 java.lang.String getJndiLocation()
          Returns the jndiLocation.
 void setJndiLocation(java.lang.String jndiLocation)
          Sets the jndiLocation.
 
クラス org.apache.log4j.db.ConnectionSourceSkeleton から継承されたメソッド
discoverConnnectionProperties, getOverriddenSupportsGetGeneratedKeys, getPassword, getSQLDialectCode, getUser, setOverriddenSupportsGetGeneratedKeys, setPassword, setUser, supportsBatchUpdates, supportsGetGeneratedKeys
 
クラス org.apache.log4j.spi.ComponentBase から継承されたメソッド
getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, setLoggerRepository
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
インタフェース org.apache.log4j.spi.Component から継承されたメソッド
setLoggerRepository
 

コンストラクタの詳細

JNDIConnectionSource

public JNDIConnectionSource()
メソッドの詳細

activateOptions

public void activateOptions()
関連項目:
OptionHandler.activateOptions()

getConnection

public java.sql.Connection getConnection()
                                  throws java.sql.SQLException
インタフェース ConnectionSource の記述:
Obtain a 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 obtained
関連項目:
ConnectionSource.getConnection()

getJndiLocation

public java.lang.String getJndiLocation()
Returns the jndiLocation.

戻り値:
String

setJndiLocation

public void setJndiLocation(java.lang.String jndiLocation)
Sets the jndiLocation.

パラメータ:
jndiLocation - The jndiLocation to set


Copyright © 2010 Apache Software Foundation. All Rights Reserved.