You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Dimitri Valdin <di...@db.com> on 2003/01/13 15:56:29 UTC

JDBCAppender with JDBC 2.0 extentions

Hello,

I would like to present yet another JDBCAppender which supports batch
updates of JDBC 2.0.

/**
 * There are 2 way of configuring of the database conection:
 * 1) dataSource + optional initialContextFactory, providerUrl,
 * securityPrincipal and securityCredentials
 * 2) driver + usr + optional username and password
 * The connection can be reused or obtained new every time. This is controlled
 * by reuseConnection property.
 * sql property specifies which SQL statement is executed for each insert.
 * values property contains format characters for the insert statement.
 * Following characters are supported: c,C,d,m,p,r,t,x. They have the same meaning
 * as by {@link org.apache.log4j.PatternLayout}. There is a special '#' character
 * which is responsoible for automatic generation of primary keys.
 * JDBCAppender supports 2 optimizations:
 * 1) bufferSize > 1 and batchMode=true forces Appender to use batch updates
 * feature of JDBC 2.0. It can bring a huge performance improvement, but unfortunately
 * this feature is not supported by all database drivers.
 * 2) idHandler + sequenceName + creationRange are used for determining of primary
 * keys. For Oracle databases the JDBCOracleIDHandler can be used. Sequence must
 * exist in the database.
 * A refresh thread is used to keep connection alive (only if reuseConnection=true),
 * which executes an SQL Statement "select count(*) from testTable" after refreshMinutes
 * period. If the buffer is not empty, then pending entries will be written into
 * the database.
 * There are 2 additional properties dropTable and createTable, which contain SQL
 * statements, which are executed during appender initialization. This properties
 * should be used only for test purposes.
*/

Hier are some test results:

    // Access from PC to remote Oracle Database on SUN.
    // 500 logs (10 Threads x 10 Iterations x 5 log entries)
    // bufferSize = 1, creationRange = 1 --> time = 40.594 s
    // bufferSize = 10, creationRange = 1 --> time = 30.032 s
    // bufferSize = 1, creationRange = 10 --> time = 12.781 s
    // bufferSize = 10, creationRange = 10 --> time = 4.047 s
    // bufferSize = 20, creationRange = 20 --> time = 3.062 s
    // bufferSize = 50, creationRange = 50 --> time = 1.328 s

Any feedback is appreciated.

Regards,

Dmitry Valdin

(See attached file: JDBCAP~1.ZIP)



--

Diese E-Mail enth�lt vertrauliche und/oder rechtlich gesch�tzte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrt�mlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden.