Class JdbcDatabaseManager

  • All Implemented Interfaces:
    Flushable, AutoCloseable

    public final class JdbcDatabaseManager
    extends org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
    An AbstractDatabaseManager implementation for relational databases accessed via JDBC.
    • Method Detail

      • getJDBCDatabaseManager

        @Deprecated
        public static JdbcDatabaseManager getJDBCDatabaseManager​(String name,
                                                                 int bufferSize,
                                                                 org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource connectionSource,
                                                                 String tableName,
                                                                 org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig[] columnConfigs)
        Creates a JDBC manager for use within the JdbcAppender, or returns a suitable one if it already exists.
        Parameters:
        name - The name of the manager, which should include connection details and hashed passwords where possible.
        bufferSize - The size of the log event buffer.
        connectionSource - The source for connections to the database.
        tableName - The name of the database table to insert log events into.
        columnConfigs - Configuration information about the log table columns.
        Returns:
        a new or existing JDBC manager as applicable.
      • getManager

        @Deprecated
        public static JdbcDatabaseManager getManager​(String name,
                                                     int bufferSize,
                                                     org.apache.logging.log4j.core.Layout<? extends Serializable> layout,
                                                     org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource connectionSource,
                                                     String tableName,
                                                     org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig[] columnConfigs,
                                                     org.apache.logging.log4j.core.appender.db.ColumnMapping[] columnMappings)
        Deprecated.
        Creates a JDBC manager for use within the JdbcAppender, or returns a suitable one if it already exists.
        Parameters:
        name - The name of the manager, which should include connection details and hashed passwords where possible.
        bufferSize - The size of the log event buffer.
        layout - The Appender-level layout
        connectionSource - The source for connections to the database.
        tableName - The name of the database table to insert log events into.
        columnConfigs - Configuration information about the log table columns.
        columnMappings - column mapping configuration (including type conversion).
        Returns:
        a new or existing JDBC manager as applicable.
      • getManager

        @Deprecated
        public static JdbcDatabaseManager getManager​(String name,
                                                     int bufferSize,
                                                     org.apache.logging.log4j.core.Layout<? extends Serializable> layout,
                                                     org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource connectionSource,
                                                     String tableName,
                                                     org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig[] columnConfigs,
                                                     org.apache.logging.log4j.core.appender.db.ColumnMapping[] columnMappings,
                                                     boolean immediateFail,
                                                     long reconnectIntervalMillis)
        Creates a JDBC manager for use within the JdbcAppender, or returns a suitable one if it already exists.
        Parameters:
        name - The name of the manager, which should include connection details and hashed passwords where possible.
        bufferSize - The size of the log event buffer.
        layout - the Appender-level layout
        connectionSource - The source for connections to the database.
        tableName - The name of the database table to insert log events into.
        columnConfigs - Configuration information about the log table columns.
        columnMappings - column mapping configuration (including type conversion).
        reconnectIntervalMillis - How often to reconnect to the database when a SQL exception is detected.
        immediateFail - Whether to fail immediately with a AppenderLoggingException when connecting to JDBC fails.
        Returns:
        a new or existing JDBC manager as applicable.
      • getManager

        public static JdbcDatabaseManager getManager​(String name,
                                                     int bufferSize,
                                                     org.apache.logging.log4j.core.Layout<? extends Serializable> layout,
                                                     org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource connectionSource,
                                                     String tableName,
                                                     org.apache.logging.log4j.core.appender.db.jdbc.ColumnConfig[] columnConfigs,
                                                     org.apache.logging.log4j.core.appender.db.ColumnMapping[] columnMappings,
                                                     boolean immediateFail,
                                                     long reconnectIntervalMillis,
                                                     boolean truncateStrings)
        Creates a JDBC manager for use within the JdbcAppender, or returns a suitable one if it already exists.
        Parameters:
        name - The name of the manager, which should include connection details and hashed passwords where possible.
        bufferSize - The size of the log event buffer.
        layout - The Appender-level layout
        connectionSource - The source for connections to the database.
        tableName - The name of the database table to insert log events into.
        columnConfigs - Configuration information about the log table columns.
        columnMappings - column mapping configuration (including type conversion).
        immediateFail - Whether or not to fail immediately with a AppenderLoggingException when connecting to JDBC fails.
        reconnectIntervalMillis - How often to reconnect to the database when a SQL exception is detected.
        truncateStrings - Whether or not to truncate strings to match column metadata.
        Returns:
        a new or existing JDBC manager as applicable.
      • closeResources

        protected void closeResources​(boolean logExceptions)
      • commitAndClose

        protected boolean commitAndClose()
        Specified by:
        commitAndClose in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
      • connectAndStart

        protected void connectAndStart()
        Specified by:
        connectAndStart in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
      • getConnectionSource

        public org.apache.logging.log4j.core.appender.db.jdbc.ConnectionSource getConnectionSource()
      • getSqlStatement

        public String getSqlStatement()
      • getTableName

        public String getTableName()
      • shutdownInternal

        protected boolean shutdownInternal()
        Specified by:
        shutdownInternal in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
      • startupInternal

        protected void startupInternal()
                                throws Exception
        Specified by:
        startupInternal in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
        Throws:
        Exception
      • writeInternal

        protected void writeInternal​(org.apache.logging.log4j.core.LogEvent event,
                                     Serializable serializable)
        Specified by:
        writeInternal in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager
      • writeThrough

        protected void writeThrough​(org.apache.logging.log4j.core.LogEvent event,
                                    Serializable serializable)
        Overrides:
        writeThrough in class org.apache.logging.log4j.core.appender.db.AbstractDatabaseManager