org.apache.log.output.db

Class DefaultJDBCTarget

Implemented Interfaces:
ErrorAware, LogTarget
Known Direct Subclasses:
NormalizedJDBCTarget

public class DefaultJDBCTarget
extends AbstractJDBCTarget

The basic DB target for configurable output formats.
Authors:
Avalon Development Team
Peter Donald

Constructor Summary

DefaultJDBCTarget(DataSource dataSource, String table, ColumnInfo[] columns)
Creation of a new JDBC logging target.

Method Summary

protected void
closeConnection()
Close connection to underlying database.
protected ColumnInfo
getColumn(int index)
Return the column info for an supplied index.
protected String
getStatementSQL()
Return the SQL insert statement.
protected String
getTable()
Return the underlying table
protected boolean
isStale()
Test if the target is stale.
protected void
openConnection()
Open connection to underlying database.
protected void
output(LogEvent event)
Output a log event to DB.
protected void
specifyColumn(PreparedStatement statement, int index, LogEvent event)
Adds a single object into statement.

Methods inherited from class org.apache.log.output.db.AbstractJDBCTarget

checkConnection, close, closeConnection, doProcessEvent, getConnection, isStale, open, openConnection, output

Methods inherited from class org.apache.log.output.AbstractTarget

close, doProcessEvent, error, getErrorHandler, isOpen, open, processEvent, setErrorHandler

Constructor Details

DefaultJDBCTarget

public DefaultJDBCTarget(DataSource dataSource,
                         String table,
                         ColumnInfo[] columns)
Creation of a new JDBC logging target.
Parameters:
dataSource - the JDBC datasource
table - the table
columns - a ColumnInfo array

Method Details

closeConnection

protected void closeConnection()
Close connection to underlying database.
Overrides:
closeConnection in interface AbstractJDBCTarget

getColumn

protected final ColumnInfo getColumn(int index)
Return the column info for an supplied index.
Parameters:
index - the index
Returns:
the column info

getStatementSQL

protected String getStatementSQL()
Return the SQL insert statement.
Returns:
the statement

getTable

protected final String getTable()
Return the underlying table
Returns:
the table name

isStale

protected boolean isStale()
Test if the target is stale.
Overrides:
isStale in interface AbstractJDBCTarget
Returns:
TRUE if the target is stale else FALSE

openConnection

protected void openConnection()
Open connection to underlying database.
Overrides:
openConnection in interface AbstractJDBCTarget

output

protected void output(LogEvent event)
Output a log event to DB. This must be implemented by subclasses.
Overrides:
output in interface AbstractJDBCTarget
Parameters:
event - the log event.

specifyColumn

protected void specifyColumn(PreparedStatement statement,
                             int index,
                             LogEvent event)
            throws SQLException,
                   IllegalStateException
Adds a single object into statement.
Parameters:
statement - the prepard statement
index - the index
event - the log event