Top Description Fields Constructors Methods
org.apache.log.output.db

public Class DefaultJDBCTarget

extends AbstractJDBCTarget
Class Inheritance
Known Direct Subclasses
org.apache.log.output.db.NormalizedJDBCTarget
Imports
java.io.StringWriter, java.sql.Connection, .PreparedStatement, .SQLException, .Timestamp, javax.sql.DataSource, org.apache.log.ContextMap, .LogEvent

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

Field Summary

Modifier and TypeField and Description
private final ColumnInfo[]
private PreparedStatement
private final String

Constructor Summary

AccessConstructor and Description
public
DefaultJDBCTarget(final DataSource
the JDBC datasource
dataSource
,
final String
the table
table
,
final ColumnInfo[]
a ColumnInfo array
columns
)

Creation of a new JDBC logging target.

Method Summary

Modifier and TypeMethod and Description
protected synchronized void
closeConnection()

Overrides org.apache.log.output.db.AbstractJDBCTarget.closeConnection.

Close connection to underlying database.
protected final ColumnInfo

Returns:

the column info
getColumn
(final int
the index
index
)

Return the column info for an supplied index.

private String
getContextMap(final ContextMap map, final String aux)

private String
getStackTrace(final Throwable throwable)

protected String

Returns:

the statement
getStatementSQL
()

Return the SQL insert statement.

protected final String

Returns:

the table name
getTable
()

Return the underlying table

protected boolean

Returns:

TRUE if the target is stale else FALSE
isStale
()

Overrides org.apache.log.output.db.AbstractJDBCTarget.isStale.

Test if the target is stale.
protected synchronized void
openConnection()

Overrides org.apache.log.output.db.AbstractJDBCTarget.openConnection.

Open connection to underlying database.
protected synchronized void
output(final LogEvent
the log event.
event
)

Implements abstract org.apache.log.output.db.AbstractJDBCTarget.output.

Output a log event to DB.
protected void
specifyColumn(final PreparedStatement
the prepard statement
statement
,
final int
the index
index
,
final LogEvent
the log event
event
)

Adds a single object into statement.

Inherited from org.apache.log.output.db.AbstractJDBCTarget:
checkConnectionclosedoProcessEventgetConnectionopen

Field Detail

m_columnsback to summary
private final ColumnInfo[] m_columns
m_statementback to summary
private PreparedStatement m_statement
m_tableback to summary
private final String m_table

Constructor Detail

DefaultJDBCTargetback to summary
public DefaultJDBCTarget(final DataSource dataSource, final String table, final ColumnInfo[] columns)

Creation of a new JDBC logging target.

Parameters
dataSource:DataSource

the JDBC datasource

table:String

the table

columns:ColumnInfo[]

a ColumnInfo array

Method Detail

closeConnectionback to summary
protected synchronized void closeConnection()

Overrides org.apache.log.output.db.AbstractJDBCTarget.closeConnection.

Close connection to underlying database.

getColumnback to summary
protected final ColumnInfo getColumn(final int index)

Return the column info for an supplied index.

Parameters
index:int

the index

Returns:ColumnInfo

the column info

getContextMapback to summary
private String getContextMap(final ContextMap map, final String aux)
getStackTraceback to summary
private String getStackTrace(final Throwable throwable)
getStatementSQLback to summary
protected String getStatementSQL()

Return the SQL insert statement.

Returns:String

the statement

getTableback to summary
protected final String getTable()

Return the underlying table

Returns:String

the table name

isStaleback to summary
protected boolean isStale()

Overrides org.apache.log.output.db.AbstractJDBCTarget.isStale.

Test if the target is stale.

Returns:boolean

TRUE if the target is stale else FALSE

openConnectionback to summary
protected synchronized void openConnection()

Overrides org.apache.log.output.db.AbstractJDBCTarget.openConnection.

Open connection to underlying database.

outputback to summary
protected synchronized void output(final LogEvent event)

Implements abstract org.apache.log.output.db.AbstractJDBCTarget.output.

Output a log event to DB. This must be implemented by subclasses.

Parameters
event:LogEvent

the log event.

specifyColumnback to summary
protected void specifyColumn(final PreparedStatement statement, final int index, final LogEvent event) throws SQLException, IllegalStateException

Adds a single object into statement.

Parameters
statement:PreparedStatement

the prepard statement

index:int

the index

event:LogEvent

the log event

Exceptions
SQLException:
if an SQL related error occurs
IllegalStateException:
if the supplied index is out of bounds