Class DataSourceConnectionSource
- java.lang.Object
-
- org.apache.logging.log4j.core.appender.db.jdbc.DataSourceConnectionSource
-
- All Implemented Interfaces:
ConnectionSource
@Plugin(name="DataSource", category="Core", elementType="connectionSource", printObject=true) public final class DataSourceConnectionSource extends java.lang.Object implements ConnectionSource
AJdbcAppender
connection source that uses aDataSource
to connect to the database.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DataSourceConnectionSource
createConnectionSource(java.lang.String jndiName)
Factory method for creating a connection source within the plugin manager.java.sql.Connection
getConnection()
This should return a new connection every time it is called.java.lang.String
toString()
All implementations must overrideObject.toString()
to provide information about the connection configuration (obscuring passwords with one-way hashes).
-
-
-
Method Detail
-
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.- Specified by:
getConnection
in interfaceConnectionSource
- Returns:
- the SQL connection object.
- Throws:
java.sql.SQLException
- if a database error occurs.
-
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.
-
createConnectionSource
@PluginFactory public static DataSourceConnectionSource createConnectionSource(@PluginAttribute("jndiName") java.lang.String jndiName)
Factory method for creating a connection source within the plugin manager.- Parameters:
jndiName
- The full JNDI path where the data source is bound. Should start with java:/comp/env or environment-equivalent.- Returns:
- the created connection source.
-
-