Holger's Java API

## com.antelmann.util.logging
Class JDBCLogWriter

    java.lang.Object
      com.antelmann.util.logging.AbstractLogWriter<RowItem>
          com.antelmann.util.logging.JDBCLogWriter

All Implemented Interfaces:
  Filter<LogEntry>, LogWriter, Closeable

    public class JDBCLogWriter

extends AbstractLogWriter<RowItem>
implements Closeable

JDBCLogWriter provides a LogWriter that writes to a java.sql.Connection. It requires a LogEntryFormatter that converts the LogEntry object to a RowItem object. This implementation is only suitable for those implementations where it is sufficient to store the LogEntry data into a single row of a single table.

Author:
  Holger Antelmann
See Also:
  `ConnectionHelper.insertRow(String, Object[])`

Field Summary
`protected ConnectionHelper` `helper`

Fields inherited from class com.antelmann.util.logging.AbstractLogWriter
`filter`

Fields inherited from interface com.antelmann.util.Filter
`EXCLUDE_ALL_FILTER, INCLUDE_ALL_FILTER`

Constructor Summary
`JDBCLogWriter(Connection con, LogEntryFormatter<RowItem> formatter)` requires a formatter that will split log entries in an object array which corresponds to the fields in the given table.

Method Summary
`void` `close()` closes the underlying connection
`ConnectionHelper` `getConnectionHelper()` returns the helper instance in use on writing the log pattern
`void` `writeLogPattern(RowItem row)` the entry is split into an object array by the formatter which is then inserted into the table.

Methods inherited from class com.antelmann.util.logging.AbstractLogWriter
`accept, getLogFilter, getLogFormatter, setLogFilter, setLogFormatter, write`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### helper

    protected ConnectionHelper helper

Constructor Detail

### JDBCLogWriter

    public JDBCLogWriter(Connection con,
                         LogEntryFormatter<RowItem> formatter)

  requires a formatter that will split log entries in an object array which corresponds to the fields in the given table.

  See Also:
    `ConnectionHelper.insertRow(String, Object[])`

Method Detail

### writeLogPattern

    public void writeLogPattern(RowItem row)
                         throws LogException

  the entry is split into an object array by the formatter which is then inserted into the table. For more sophisticated storage that requires more than one table (if e.g. a variable number of parameters are to be stored in a separate table) a different implementation would be required.

  Specified by:
    `writeLogPattern` in class `AbstractLogWriter<RowItem>`
  Throws:
    `LogException`
  See Also:
    `ConnectionHelper.insertRow(String, Object[])`

### getConnectionHelper

    public ConnectionHelper getConnectionHelper()

  returns the helper instance in use on writing the log pattern

### close

    public void close()
               throws IOException

  closes the underlying connection

  Specified by:
    `close` in interface `Closeable`
  Throws:
    `IOException`

(c) Holger Antelmann since 2001- all rights reserved (contact: info@antelmann.com)
see www.antelmann.com/developer for further details and available downloads