org.apache.logging.log4j.core.appender.db.jdbc
Class DriverManagerConnectionSource

java.lang.Object
  extended by org.apache.logging.log4j.core.appender.db.jdbc.DriverManagerConnectionSource
All Implemented Interfaces:
ConnectionSource

public final class DriverManagerConnectionSource
extends Object
implements ConnectionSource

A JDBCAppender connection source that uses a standard JDBC URL, username, and password to connect to the database.


Method Summary
static DriverManagerConnectionSource createConnectionSource(String url, String username, String password)
          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

public static DriverManagerConnectionSource createConnectionSource(String url,
                                                                   String username,
                                                                   String password)
Factory method for creating a connection source within the plugin manager.

Parameters:
url - The JDBC URL to use to connect to the logging database. A driver that can accept this URL must be on the classpath.
username - The username with which to log in to the database, if applicable.
password - The password with which to log in to the database, if applicable.
Returns:
the created connection source.


Copyright © 1999-2013 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.