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!