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[])
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
helper
protected ConnectionHelper helper
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[])
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