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
A
ConnectionSource
that uses a JDBC connection string, a user name, and a password to call
DriverManager.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
Modifier and TypeClassDescriptionstatic 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
ConstructorDescriptionAbstractDriverManagerConnectionSource
(String driverClassName, String connectionString, String actualConnectionString, char[] userName, char[] password, Property[] properties) -
Method Summary
Modifier and TypeMethodDescriptionThis should return a new connection every time it is called.static Logger
char[]
Property[]
char[]
protected void
protected void
loadDriver
(String className) Loads a JDBC driver for the given class nameprotected Properties
toProperties
(Property[] properties) toString()
All implementations must overrideObject.toString()
to provide information about the connection configuration (obscuring passwords with one-way hashes).protected 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 Details
-
AbstractDriverManagerConnectionSource
-
-
Method Details
-
getLogger
-
getActualConnectionString
-
getConnection
Description copied from interface:ConnectionSource
This should return a new connection every time it is called.- Returns:
- the SQL connection object.
- Throws:
SQLException
- if a database error occurs.
-
getConnectionString
-
getDriverClassName
-
getPassword
public char[] getPassword() -
getProperties
-
getUserName
public char[] getUserName() -
loadDriver
- Throws:
SQLException
-
loadDriver
Loads a JDBC driver for the given class name- Parameters:
className
- the fully-qualified class name for a JDBC Driver.- Throws:
SQLException
- thrown when loading the driver throws an exception.
-
toProperties
-
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 classObject
- Returns:
- the string representation of this connection source.
-
toString
-