Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.logging.log4j.core.appender.db.jdbc
Class FactoryMethodConnectionSource

    java.lang.Object
      org.apache.logging.log4j.core.appender.db.jdbc.FactoryMethodConnectionSource

All Implemented Interfaces:
  ConnectionSource

    @Plugin(name="ConnectionFactory",
            category="Core",
            elementType="connectionSource",
            printObject=true)
    public final class FactoryMethodConnectionSource

extends Object
implements ConnectionSource

A `JdbcAppender` connection source that uses a public static factory method to obtain a `Connection` or `DataSource`.

Method Summary
`static FactoryMethodConnectionSource` | `createConnectionSource(String className, String methodName)` Factory method for creating a connection source within the plugin manager.
`Connection` | `getConnection()` This should return a new connection every time it is called.
`String` | `toString()` All implementations must override `Object.toString()` to provide information about the connection configuration (obscuring passwords with one-way hashes).

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Method Detail

### getConnection

    public Connection getConnection()
                             throws SQLException

  Description copied from interface: `ConnectionSource`
  This should return a new connection every time it is called.

  Specified by:
    `getConnection` in interface `ConnectionSource`
  Returns:
    the SQL connection object.
  Throws:
    `SQLException` - if a database error occurs.

### toString

    public String toString()

  Description copied from interface: `ConnectionSource`
  All implementations must override `Object.toString()` to provide information about the connection configuration (obscuring passwords with one-way hashes).

  Specified by:
    `toString` in interface `ConnectionSource`
  Overrides:
    `toString` in class `Object`
  Returns:
    the string representation of this connection source.

### createConnectionSource

    @PluginFactory
    public static FactoryMethodConnectionSource createConnectionSource(@PluginAttribute(value="class")
                                                                                     String className,
                                                                                     @PluginAttribute(value="method")
                                                                                     String methodName)

  Factory method for creating a connection source within the plugin manager.

  Parameters:
    `className` - The name of a public class that contains a static method capable of returning either a `DataSource` or a `Connection`.
    `methodName` - The name of the public static method on the aforementioned class that returns the data source or connection. If this method returns a `Connection`, it should return a new connection every call.
  Returns:
    the created connection source.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 1999-2015 Apache Software Foundation. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.