Class AbstractDriverManagerConnectionSource
- java.lang.Object
-
- org.apache.logging.log4j.core.AbstractLifeCycle
-
- org.apache.logging.log4j.core.appender.db.jdbc.AbstractConnectionSource
-
- org.apache.logging.log4j.core.appender.db.jdbc.AbstractDriverManagerConnectionSource
-
- All Implemented Interfaces:
ConnectionSource
,LifeCycle
,LifeCycle2
- Direct Known Subclasses:
DriverManagerConnectionSource
public class AbstractDriverManagerConnectionSource extends AbstractConnectionSource
AConnectionSource
that uses a JDBC connection string, a user name, and a password to callDriverManager.getConnection(String, String, String)
.This plugin does not provide any connection pooling unless it is available through the connection string and driver itself. This handy to get you off the ground without having to deal with JNDI.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AbstractDriverManagerConnectionSource.Builder<B extends AbstractDriverManagerConnectionSource.Builder<B>>
Builds DriverManagerConnectionSource instances.-
Nested classes/interfaces inherited from interface org.apache.logging.log4j.core.LifeCycle
LifeCycle.State
-
-
Field Summary
-
Fields inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
DEFAULT_STOP_TIMEOUT, DEFAULT_STOP_TIMEUNIT
-
-
Constructor Summary
Constructors Constructor Description AbstractDriverManagerConnectionSource(java.lang.String driverClassName, java.lang.String connectionString, java.lang.String actualConnectionString, char[] userName, char[] password, Property[] properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getActualConnectionString()
java.sql.Connection
getConnection()
This should return a new connection every time it is called.java.lang.String
getConnectionString()
java.lang.String
getDriverClassName()
static Logger
getLogger()
char[]
getPassword()
Property[]
getProperties()
char[]
getUserName()
protected void
loadDriver()
protected void
loadDriver(java.lang.String className)
Loads a JDBC driver for the given class nameprotected java.util.Properties
toProperties(Property[] properties)
java.lang.String
toString()
All implementations must overrideObject.toString()
to provide information about the connection configuration (obscuring passwords with one-way hashes).protected java.lang.String
toString(char[] value)
-
Methods inherited from class org.apache.logging.log4j.core.AbstractLifeCycle
equalsImpl, getState, getStatusLogger, hashCodeImpl, initialize, isInitialized, isStarted, isStarting, isStopped, isStopping, setStarted, setStarting, setState, setStopped, setStopping, start, stop, stop, stop
-
-
-
-
Constructor Detail
-
AbstractDriverManagerConnectionSource
public AbstractDriverManagerConnectionSource(java.lang.String driverClassName, java.lang.String connectionString, java.lang.String actualConnectionString, char[] userName, char[] password, Property[] properties)
-
-
Method Detail
-
getLogger
public static Logger getLogger()
-
getActualConnectionString
public java.lang.String getActualConnectionString()
-
getConnection
public java.sql.Connection getConnection() throws java.sql.SQLException
Description copied from interface:ConnectionSource
This should return a new connection every time it is called.- Returns:
- the SQL connection object.
- Throws:
java.sql.SQLException
- if a database error occurs.
-
getConnectionString
public java.lang.String getConnectionString()
-
getDriverClassName
public java.lang.String getDriverClassName()
-
getPassword
public char[] getPassword()
-
getProperties
public Property[] getProperties()
-
getUserName
public char[] getUserName()
-
loadDriver
protected void loadDriver() throws java.sql.SQLException
- Throws:
java.sql.SQLException
-
loadDriver
protected void loadDriver(java.lang.String className) throws java.sql.SQLException
Loads a JDBC driver for the given class name- Parameters:
className
- the fully-qualified class name for a JDBC Driver.- Throws:
java.sql.SQLException
- thrown when loading the driver throws an exception.
-
toProperties
protected java.util.Properties toProperties(Property[] properties)
-
toString
public java.lang.String toString()
Description copied from interface:ConnectionSource
All implementations must overrideObject.toString()
to provide information about the connection configuration (obscuring passwords with one-way hashes).- Specified by:
toString
in interfaceConnectionSource
- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string representation of this connection source.
-
toString
protected java.lang.String toString(char[] value)
-
-