Package org.apache.log.output.db
Class DefaultJDBCTarget
java.lang.Object
org.apache.log.output.AbstractTarget
org.apache.log.output.db.AbstractJDBCTarget
org.apache.log.output.db.DefaultJDBCTarget
- All Implemented Interfaces:
ErrorAware,LogTarget,Closeable
- Direct Known Subclasses:
NormalizedJDBCTarget
The basic DB target for configurable output formats.
- Author:
- Avalon Development Team, Peter Donald
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ColumnInfo[]private PreparedStatementprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionDefaultJDBCTarget(DataSource dataSource, String table, ColumnInfo[] columns) Creation of a new JDBC logging target. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidClose connection to underlying database.protected final ColumnInfogetColumn(int index) Return the column info for an supplied index.private StringgetContextMap(ContextMap map, String aux) private StringgetStackTrace(Throwable throwable) protected StringReturn the SQL insert statement.protected final StringgetTable()Return the underlying tableprotected booleanisStale()Test if the target is stale.protected voidOpen connection to underlying database.protected voidOutput a log event to DB.protected voidspecifyColumn(PreparedStatement statement, int index, LogEvent event) Adds a single object into statement.Methods inherited from class org.apache.log.output.db.AbstractJDBCTarget
checkConnection, close, doProcessEvent, getConnection, openMethods inherited from class org.apache.log.output.AbstractTarget
getErrorHandler, isOpen, processEvent, setErrorHandler
-
Field Details
-
m_table
-
m_columns
-
m_statement
-
-
Constructor Details
-
DefaultJDBCTarget
Creation of a new JDBC logging target.- Parameters:
dataSource- the JDBC datasourcetable- the tablecolumns- a ColumnInfo array
-
-
Method Details
-
output
Output a log event to DB. This must be implemented by subclasses.- Specified by:
outputin classAbstractJDBCTarget- Parameters:
event- the log event.
-
openConnection
protected void openConnection()Open connection to underlying database.- Overrides:
openConnectionin classAbstractJDBCTarget
-
getStatementSQL
Return the SQL insert statement.- Returns:
- the statement
-
isStale
protected boolean isStale()Test if the target is stale.- Overrides:
isStalein classAbstractJDBCTarget- Returns:
- TRUE if the target is stale else FALSE
-
closeConnection
protected void closeConnection()Close connection to underlying database.- Overrides:
closeConnectionin classAbstractJDBCTarget
-
specifyColumn
protected void specifyColumn(PreparedStatement statement, int index, LogEvent event) throws SQLException, IllegalStateException Adds a single object into statement.- Parameters:
statement- the prepard statementindex- the indexevent- the log event- Throws:
SQLException- if an SQL related error occursIllegalStateException- if the supplied index is out of bounds
-
getTable
Return the underlying table- Returns:
- the table name
-
getColumn
Return the column info for an supplied index.- Parameters:
index- the index- Returns:
- the column info
-
getStackTrace
-
getContextMap
-