org.apache.log4j.db
クラス DriverManagerConnectionSource

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

public class DriverManagerConnectionSource
extends ConnectionSourceSkeleton

The DriverManagerConnectionSource is an implementation of ConnectionSource that obtains the Connection in the traditional JDBC manner based on the connection URL.

Note that this class will establish a new Connection for each call to getConnection(). It is recommended that you either use a JDBC driver that natively supported Connection pooling or that you create your own implementation of ConnectionSource that taps into whatever pooling mechanism you are already using. (If you have access to a JNDI implementation that supports DataSources, e.g. within a J2EE application server, see JNDIConnectionSource). See below for a configuration example that uses the commons-dbcp package from Apache.

Sample configuration:

     <connectionSource class="org.apache.log4j.jdbc.DriverManagerConnectionSource">
        <param name="driver" value="com.mysql.jdbc.Driver" />
        <param name="url" value="jdbc:mysql://localhost:3306/mydb" />
        <param name="username" value="myUser" />
        <param name="password" value="myPassword" />
     </connectionSource>
  

If you do not have another connection pooling mechanism built into your application, you can use the commons-dbcp package from Apache:

     <connectionSource class="org.apache.log4j.jdbc.DriverManagerConnectionSource">
        <param name="driver" value="org.apache.commons.dbcp.PoolingDriver" />
        <param name="url" value="jdbc:apache:commons:dbcp:/myPoolingDriver" />
     </connectionSource>
  
Then the configuration information for the commons-dbcp package goes into the file myPoolingDriver.jocl and is placed in the classpath. See the commons-dbcp documentation for details.

作成者:
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
 
コンストラクタの概要
DriverManagerConnectionSource()
           
 
メソッドの概要
 void activateOptions()
           
 java.sql.Connection getConnection()
          Obtain a Connection for use.
 java.lang.String getDriverClass()
          Returns the name of the driver class.
 java.lang.String getUrl()
          Returns the url.
 void setDriverClass(java.lang.String driverClass)
          Sets the driver class.
 void setUrl(java.lang.String url)
          Sets the url.
 
クラス 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
 

コンストラクタの詳細

DriverManagerConnectionSource

public DriverManagerConnectionSource()
メソッドの詳細

activateOptions

public void 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()

getUrl

public java.lang.String getUrl()
Returns the url.

戻り値:
String

setUrl

public void setUrl(java.lang.String url)
Sets the url.

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

getDriverClass

public java.lang.String getDriverClass()
Returns the name of the driver class.

戻り値:
String

setDriverClass

public void setDriverClass(java.lang.String driverClass)
Sets the driver class.

パラメータ:
driverClass - The driver class to set


Copyright © 2010 Apache Software Foundation. All Rights Reserved.