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 PreparedStatement
private final String
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultJDBCTarget
(DataSource dataSource, String table, ColumnInfo[] columns) Creation of a new JDBC logging target. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Close connection to underlying database.protected final ColumnInfo
getColumn
(int index) Return the column info for an supplied index.private String
getContextMap
(ContextMap map, String aux) private String
getStackTrace
(Throwable throwable) protected String
Return the SQL insert statement.protected final String
getTable()
Return the underlying tableprotected boolean
isStale()
Test if the target is stale.protected void
Open connection to underlying database.protected void
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, doProcessEvent, getConnection, open
Methods 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:
output
in classAbstractJDBCTarget
- Parameters:
event
- the log event.
-
openConnection
protected void openConnection()Open connection to underlying database.- Overrides:
openConnection
in classAbstractJDBCTarget
-
getStatementSQL
Return the SQL insert statement.- Returns:
- the statement
-
isStale
protected boolean isStale()Test if the target is stale.- Overrides:
isStale
in classAbstractJDBCTarget
- Returns:
- TRUE if the target is stale else FALSE
-
closeConnection
protected void closeConnection()Close connection to underlying database.- Overrides:
closeConnection
in 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
-