Posted by: Arthur Blake | 2009-02-26

log4jdbc 1.2 alpha 2 released!

The next alpha release for log4jdbc is out! Get it while it’s hot….

1. Fixed a bug with batched SQL in this release (thanks to Daniel Doubleday for reporting this)

2. Added simple getter methods for all the underlying wrapped objects.

For example, you can get the real Connection from the ConnectionSpy like this:

Connection realConnection = ((ConnectionSpy) conn).getRealConnection();

or you can get the real Statement from the StatementSpy like this:

Statement realStmt = ((StatementSpy) stmt).getRealStatement();

The simple getter methods added to log4jdbc were also added to the JDBC 4 version for consistency but please keep in mind that if you are lucky enough to be using JDBC 4, it’s best to use the more powerful Wrapper interface (which has always been fully supported in the JDBC 4 version of log4jdbc.)

I’ve been meaning to add this feature for awhile, but was prompted again by this issue raised by jrobertray.

3. Finally, I’ve added a new option for turning off SQL Statement warnings. log4jdbc has always included warnings in the logs when simple Statements were used to execute SQL. This is because a database can usually pre-compile and cache PreparedStatements much more efficiently (especially when running many many similar SQL statements with only differing bind variables.) Also, using Statements can sometimes have security implications if used improperly (binding variables is much cleaner than concatenating strings together to form your SQL!) I’ve realized that this warning might annoy some people (aka me!), so I’ve turned it off by default. You can turn it back on by setting the log4jdbc.statement.warn system property to true.

I hope you enjoy this release, and as always, please send me feedback!



  1. I think it can handle that load as long as you use INFO level logging (DEBUG level logging does extra processing that can be slow in some environments).

    The code is pretty transparent and designed for speed. But I haven’t done any kind of performance or load testing of it under that kind of load, so use it at your own risk.

    Also bear in mind that the tool is mostly for logging and not strictly a profiler. You can however log query times in the output, and there is a tool you can use to post-process the log to produce a list of the top slow performing queries. The tool is pretty rudimentary at this point though.

  2. I know this post is quite old, but I just wanted to say thank you for log4jdbc. I use it in all my projects 🙂

    • You’re welcome! Glad to be of service.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: