org.apache.log4j.receivers.db

## Class DataSourceConnectionSource

- java.lang.Object
- - org.apache.log4j.component.spi.ComponentBase
  - - org.apache.log4j.receivers.db.ConnectionSourceSkeleton
    - - org.apache.log4j.receivers.db.DataSourceConnectionSource

- All Implemented Interfaces:
    Component, ConnectionSource, org.apache.log4j.spi.OptionHandler, org.apache.log4j.xml.UnrecognizedElementHandler

      public class DataSourceConnectionSource
      extends ConnectionSourceSkeleton
      implements org.apache.log4j.xml.UnrecognizedElementHandler

  The DataSourceConnectionSource is an implementation of `ConnectionSource` that obtains the Connection in the recommended JDBC manner based on a `DataSource`.

  Author:
    Ray DeCampo, Ceki Gülcü

- - ### Field Summary

    - ### Fields inherited from class org.apache.log4j.component.spi.ComponentBase

      `repository`

    - ### Fields inherited from interface org.apache.log4j.receivers.db.ConnectionSource

      `HSQL_DIALECT, MSSQL_DIALECT, MYSQL_DIALECT, ORACLE_DIALECT, POSTGRES_DIALECT, UNKNOWN_DIALECT`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DataSourceConnectionSource()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `activateOptions()`
    `Connection` | `getConnection()` Obtain a `Connection` for use.
    `DataSource` | `getDataSource()`
    `boolean` | `parseUnrecognizedElement(Element element, Properties props)`
    `void` | `setDataSource(DataSource dataSource)`

    - ### Methods inherited from class org.apache.log4j.receivers.db.ConnectionSourceSkeleton

      `discoverConnnectionProperties, getOverriddenSupportsGetGeneratedKeys, getPassword, getSQLDialectCode, getUser, setOverriddenSupportsGetGeneratedKeys, setPassword, setUser, supportsBatchUpdates, supportsGetGeneratedKeys`

    - ### Methods inherited from class org.apache.log4j.component.spi.ComponentBase

      `getLogger, getLoggerRepository, getNonFloodingLogger, resetErrorCount, 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.component.spi.Component

      `setLoggerRepository`

- - ### Constructor Detail

    - #### DataSourceConnectionSource

          public DataSourceConnectionSource()

  - ### Method Detail

    - #### activateOptions

          public void activateOptions()

      Specified by:
        `activateOptions` in interface `org.apache.log4j.spi.OptionHandler`

    - #### getConnection

          public Connection getConnection()
                                   throws SQLException

      Description copied from interface: `ConnectionSource`
      Obtain a `Connection` for use. The client is responsible for closing the `Connection` when it is no longer required.
      Specified by:
        `getConnection` in interface `ConnectionSource`
      Throws:
        `SQLException` - if a `Connection` could not be obtained
      See Also:
        `ConnectionSource.getConnection()`

    - #### getDataSource

          public DataSource getDataSource()

    - #### setDataSource

          public void setDataSource(DataSource dataSource)

    - #### parseUnrecognizedElement

          public boolean parseUnrecognizedElement(Element element,
                                         Properties props)
                                           throws Exception

      Specified by:
        `parseUnrecognizedElement` in interface `org.apache.log4j.xml.UnrecognizedElementHandler`
      Throws:
        `Exception`

Copyright © 2013 The Apache Software Foundation. Licensed under the Apache License, Version 2.0

Apache Extras for Apache log4j, Apache log4j and Apache are trademarks of the Apache Software Foundation.