mirror of
https://github.com/encounter/log4jdbc.git
synced 2026-03-30 11:27:21 -07:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2223543ff0 | |||
| 89ed31f0b8 | |||
| 29b2b01ee1 | |||
| 0a4f5267df | |||
| a7ebd7eb1f | |||
| 48cb541e58 | |||
| 201d3b974b | |||
| 007ff20ed1 | |||
| 2d8cbd4cdf | |||
| 21cbf688ec | |||
| 44043261af | |||
| 86364a24fa | |||
| 4900e751bb | |||
| 9da5241e39 | |||
| ddbee4d1b6 | |||
| 6bf61ef02b | |||
| 18c7e2fd19 | |||
| 339682f0c9 | |||
| b9ac53c3f3 | |||
| 1695b42ce1 | |||
| a072c4e953 | |||
| 567cefd156 | |||
| 90608d8ff1 | |||
| 425148e118 | |||
| 328a6da56f | |||
| 8c6125a59c | |||
| 8ab139da54 | |||
| 41064c0bc4 | |||
| 2ca89b4f6e |
+122
-10
@@ -1,20 +1,132 @@
|
||||
2009-02-26 1.2 alpha 2 Release
|
||||
|
||||
o (Issue 1) fix bug where batch of logged SQL wasn't cleared
|
||||
properly when using batched SQL.
|
||||
|
||||
o Added log4jdbc.statement.warn system property; defaults to false.
|
||||
|
||||
This is a new option to control the SQL Statement warnings in the
|
||||
log. When Statement objects are used by the application, the SQL
|
||||
in the log is preceded by "{WARNING: Statement used to run SQL}"
|
||||
This was always on in previous releases. Now it
|
||||
is off by default, and can be turned on by setting this property.
|
||||
|
||||
o (Issue 2) add getter methods across the board for the real
|
||||
wrapped object.
|
||||
|
||||
2008-11-08 1.2 alpha 1 Release
|
||||
|
||||
o added a new logger "jdbc.connection" to dump connection open and
|
||||
close events as well as dumping all open connection numbers. This
|
||||
is very useful for hunting down connection leak problems.
|
||||
|
||||
o several new options to produce better SQL output:
|
||||
|
||||
log4jdbc.dump.booleanastruefalse - many RDBMS's don't have a
|
||||
native boolean type and store booleans as a 1 or 0. Setting this
|
||||
option to false will show boolean bind variables as 1 or 0.
|
||||
Setting this to true will show the boolean as true or false.
|
||||
(Note that the default for this setting is false, contrary to the
|
||||
previous way log4jdbc worked.)
|
||||
|
||||
log4jdbc.dump.sql.maxlinelength - can be used to insert line
|
||||
breaks into long running SQL (at white space positions.)
|
||||
previous versions of log4jdbc did this automatically with a value
|
||||
of 90 (the default value is 90.) This line breaking can be turned
|
||||
off completely by setting this to 0.
|
||||
|
||||
log4jdbc.dump.fulldebugstacktrace - can be used in extreme
|
||||
debugging circumstances when you want to be able to see the full
|
||||
stack trace in the debug output. Be extra careful when using
|
||||
this as it will obviously produce much much more logging output.
|
||||
|
||||
o dump a null bind variable as NULL instead of <null> for more
|
||||
accurate and reuseable SQL output.
|
||||
|
||||
o several new options for controlling what types of SQL statements
|
||||
are logged:
|
||||
|
||||
log4jdbc.dump.sql.select default value is true
|
||||
log4jdbc.dump.sql.insert default value is true
|
||||
log4jdbc.dump.sql.update default value is true
|
||||
log4jdbc.dump.sql.delete default value is true
|
||||
log4jdbc.dump.sql.create default value is true
|
||||
|
||||
The default values for all of these are true, but they can be
|
||||
selectively turned on and off to filter out unwanted types of sql
|
||||
statements. For example, setting log4jdbc.dump.sql.delete will
|
||||
cause all DELETE sql commands to not be logged.
|
||||
|
||||
o A new option to add a semi colon to the end of the dumped sql:
|
||||
|
||||
log4jdbc.dump.sql.addsemicolon default value is false
|
||||
|
||||
Sometimes it's useful to use log4jdbc to produce sql scripts that
|
||||
can later be fed back into a SQL tool to execute against a
|
||||
database and this option can help to produce more re-useable sql
|
||||
output script data from a log file.
|
||||
|
||||
o added Microsoft SQL Server 2005 Driver
|
||||
(com.microsoft.sqlserver.jdbc.SQLServerDriver) to
|
||||
list of "well known" drivers that log4jdbc looks for at startup.
|
||||
(thanks to Rob Richards for pointing this out)
|
||||
|
||||
Note that the SQL Server 2000 Driver with the confusing name
|
||||
of (com.microsoft.jdbc.sqlserver.SQLServerDriver) is also still
|
||||
supported.
|
||||
|
||||
o other miscellaneous improvements.
|
||||
|
||||
2008-04-11 1.1 Release
|
||||
|
||||
o upgrade to SLF4J 1.5. Note that log4jdbc should still work with
|
||||
any older (or newer) version of SLF4J too.
|
||||
|
||||
o slightly better fault tolerance for when loading/probing of
|
||||
popular JDBC drivers fails for any reason.
|
||||
|
||||
2007-11-10 1.1 beta 1 Release
|
||||
|
||||
o added HSQLDB (org.hsqldb.jdbcDriver) and H2 (org.h2.Driver) to
|
||||
list of "well known" drivers that log4jdbc looks for at startup.
|
||||
|
||||
o added log4jdbc.sqltiming.warn.threshold and
|
||||
log4jdbc.sqltiming.error.threshold system property settings to
|
||||
greatly aid in finding slow running sql. Special thanks to
|
||||
Lilianne E. Blaze for the idea and initial implementation.
|
||||
|
||||
2007-07-25 1.1 alpha 2 Release
|
||||
|
||||
o JDBC 4.0 support!
|
||||
|
||||
o fix Null pointer exception bug that could happen with setObject
|
||||
call on PreparedStatementSpy
|
||||
|
||||
o added MySQL (com.mysql.jdbc.Driver) and PostgreSQL
|
||||
(org.postgresql.Driver) to list of "well known" drivers that
|
||||
log4jdbc looks for at startup.
|
||||
|
||||
2007-05-29 1.1 alpha 1 Release
|
||||
|
||||
o Fixed problem where when sql timing log was the only log turned on, log4jdbc would not recognize that
|
||||
logging was on at all.
|
||||
o Fixed problem where when sql timing log was the only log turned
|
||||
on, log4jdbc would not recognize that logging was on at all.
|
||||
|
||||
o report sql exceptions in the sql timing log as well (when they occured during sql execution) and
|
||||
prominently show that the sql FAILED, and display how long it tried to chug on the sql
|
||||
before the exception was thrown
|
||||
o report sql exceptions in the sql timing log as well (when they
|
||||
occured during sql execution) and prominently show that the sql
|
||||
FAILED, and display how long it tried to chug on the sql before
|
||||
the exception was thrown.
|
||||
|
||||
o Switch to Simple Logging Facade for Java SLF4J instead of using log4j directly, so that any underlying
|
||||
logging system can be easily used.
|
||||
o Switch to Simple Logging Facade for Java SLF4J instead of using
|
||||
log4j directly, so that any underlying logging system can be
|
||||
easily used.
|
||||
|
||||
o option added to ant build script to generate javadoc with ydoc to include UML diagrams within the javadoc.
|
||||
o option added to ant build script to generate javadoc with ydoc
|
||||
to include UML diagrams within the javadoc.
|
||||
|
||||
o dump batched sql correctly.
|
||||
|
||||
o add simple command line program (PostLogProfilerProcessor) for processing sqltiming log files to create
|
||||
a simple profiling report from log data.
|
||||
o add simple command line program (PostLogProfilerProcessor) for
|
||||
processing sqltiming log files to create a simple profiling
|
||||
report from log data.
|
||||
|
||||
2007-04-21 Initial 1.0 Release
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
log4jdbc is open source software, released under the Apache License, Version 2.0:
|
||||
|
||||
Copyright 2007 Arthur Blake
|
||||
Copyright 2007-2008 Arthur Blake
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use log4jdbc except in compliance with the License.
|
||||
|
||||
+1
-3
@@ -1,5 +1,3 @@
|
||||
[this software is open source, released under the Apache License, Version 2.0: see LICENSE file]
|
||||
|
||||
Please see the main log4jdbc web page at http://log4jdbc.sourceforge.net for detailed features and usage information.
|
||||
There should also be in this folder, a copy of the main web page as it existed when this release was made.
|
||||
See index.html.
|
||||
Please see the main log4jdbc web page at http://log4jdbc.googlecode.com for detailed features and usage information.
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
x switch to SLF4J logging facade so that any kind of logging system can be used with log4jdbc --
|
||||
not just log4j
|
||||
|
||||
x need a way to report exceptions in the sql timing log as well as the sql that failed and how long it took to fail.
|
||||
|
||||
x include ydoc within javadoc
|
||||
|
||||
x NEED TO LOOK INTO how to support isJdbcLoggingEnabled method call for Slf4jSpyLogDelegator
|
||||
|
||||
o NEED to test & build for jdk 1.5&1.6 and jdbc 4
|
||||
|
||||
o log4layers product? log4jdbc + servlet layer logging, struts layer logging, json-rpc layer logging, request header dump?
|
||||
o what about jdbc 2 back support??
|
||||
|
||||
o configuration that doesn't rely on system properties (jdbc parms?)
|
||||
|
||||
o PostLogProfilerProcessor needs to be able to handle exceptions in log, & needs to be more efficient, also needs command
|
||||
line switches to control the thresholds & counts, etc.
|
||||
line switches to control the thresholds & counts, etc.
|
||||
|
||||
o intelligent array dumper?
|
||||
|
||||
o check for more different kinds of JDBC drivers at startup time
|
||||
|
||||
o support for data sources
|
||||
|
||||
o ALL String concatenation & dumping methods should take place ONLY if logging is ON!!
|
||||
|
||||
o review dumpedSql method - make auto line breaking option (& num chars used) be options
|
||||
|
||||
o need log4jdbc.debug.stack.regex so that the stack matching can take place via regex
|
||||
|
||||
o maven2 repository support
|
||||
|
||||
-231
@@ -1,231 +0,0 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>log4jdbc - A JDBC Driver for logging SQL and JDBC calls.</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<link rel="stylesheet" href="reset-fonts-grids.css" />
|
||||
<link rel="stylesheet" href="log4jdbc.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h1><a name="top"/><img class="logo" src="log4jdbc-logo-gray.png"><br>
|
||||
|
||||
<a href="http://sourceforge.net/project/showfiles.php?group_id=194500">download</a> |
|
||||
<a href="#news">news</a> |
|
||||
<a href="#features">features</a> |
|
||||
<a href="#usage">usage</a> |
|
||||
<a href="apidocs/net/sf/log4jdbc/package-summary.html">javadoc</a> |
|
||||
<a href="#license">license</a> |
|
||||
<a href="#feedback">feedback</a>
|
||||
</h1>
|
||||
|
||||
<p>
|
||||
<b>log4jdbc</b> is a JDBC driver that can log SQL and/or JDBC calls (and optionally SQL timing information)
|
||||
for other jdbc drivers using the <a href="http://www.slf4j.org/">Simple Logging Facade For Java</a> (SLF4J) logging system.
|
||||
</p>
|
||||
|
||||
<h2><a name="news"/>news</h2>
|
||||
<p class="left"><b>2007-05-29:</b> <a href="http://sourceforge.net/forum/forum.php?forum_id=700185">log4jdbc 1.1 alpha 1 released.</a> Most notable change is that the simple logging facade for java is now used instead of log4j directly. See <a href="CHANGES">CHANGES</a> for all the release details.</p>
|
||||
<p class="left"><b>2007-04-21:</b> <a href="http://sourceforge.net/forum/forum.php?forum_id=688372">log4jdbc 1.0 has been released!</a> Download it and give it a try!</p>
|
||||
|
||||
<p class="right"><a href="#top">[back to top]</a></p>
|
||||
<h2><a name="features"/>features</h2>
|
||||
|
||||
<ul class="left">
|
||||
<li>
|
||||
Easy to drop in and use in existing systems, because it's a standard jdbc driver.
|
||||
The only other requirement is to have the SLF4J jars and your jdbc driver for your
|
||||
database.
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Easy to configure, in most cases all you need to do is change the driver class name
|
||||
and prepend "jdbc:log4" to your existing jdbc url, set up your logging categories and
|
||||
you're ready to go!
|
||||
</li>
|
||||
|
||||
<li>
|
||||
In the logged output, for prepared statements, the bind arguments are automatically
|
||||
inserted into the SQL output. This greatly Improves readability and debugging for
|
||||
many cases.
|
||||
</li>
|
||||
|
||||
<li>
|
||||
SQL timing information can be generated to help identify how long SQL statements take
|
||||
to run, helping to identify statements that are running too slowly and this data can
|
||||
be post processed with an included tool to produce profiling report data for quickly
|
||||
identifying slow SQL in your application..
|
||||
</li>
|
||||
|
||||
<li>
|
||||
SQL connection number information is generated to help identify connection pooling or
|
||||
threading problems.
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Works with any JDBC 3.0 driver, JDK 1.4 and above, and SLF4J 1.x.
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
<p>
|
||||
This jdbc driver can be "dropped in" to log the SQL and jdbc calls of another JDBC driver.
|
||||
</p>
|
||||
|
||||
<p class="right"><a href="#top">[back to top]</a></p>
|
||||
<h2><a name="usage"/>usage</h2>
|
||||
|
||||
<ol class="left">
|
||||
|
||||
<li><p> Set your jdbc driver class to <code>net.sf.log4jdbc.DriverSpy</code> </p>
|
||||
<p>
|
||||
The underlying driver that is being spied on in many cases will be loaded automatically
|
||||
without any additional configuration.
|
||||
</p>
|
||||
<p>
|
||||
The log4jdbc "spy" driver will try and load the following popular jdbc drivers:
|
||||
</p>
|
||||
<pre>
|
||||
|
||||
oracle.jdbc.driver.OracleDriver (oracle)
|
||||
com.sybase.jdbc2.jdbc.SybDriver (sybase)
|
||||
net.sourceforge.jtds.jdbc.Driver (sourceforge ms sql server driver)
|
||||
com.microsoft.jdbc.sqlserver.SQLServerDriver (microsoft ms sql server driver)
|
||||
weblogic.jdbc.sqlserver.SQLServerDriver (weblogic ms sql server driver)
|
||||
com.informix.jdbc.IfxDriver (informix)
|
||||
org.apache.derby.jdbc.ClientDriver (apache derby client/server driver)
|
||||
org.apache.derby.jdbc.EmbeddedDriver (apache derby embedded driver)
|
||||
</pre>
|
||||
<p>
|
||||
If you want to use a different underlying jdbc driver that is not already in the above supported list,
|
||||
set a system property, log4jdbc.drivers to the class name of the additional driver. This
|
||||
can also be a comma separated list of driver class names.
|
||||
</p>
|
||||
<p>
|
||||
(optional) <code>-Dlog4jdbc.drivers=<driver>[,<driver>...]</code> If your driver is not one of the common preloaded drivers.
|
||||
</p>
|
||||
</li>
|
||||
<li><p> Prepend <code>jdbc:log4</code> to the normal jdbc url that you are using.</p>
|
||||
|
||||
<p>For example, if your normal jdbc url is <code>jdbc:derby://localhost:1527//db-derby-10.2.2.0-bin/databases/MyDatabase</code>
|
||||
You would change it to: <code>jdbc:log4jdbc:derby://localhost:1527//db-derby-10.2.2.0-bin/databases/MyDatabase</code> to use the
|
||||
log4jdbc spy driver.</p>
|
||||
</li>
|
||||
<li><p>Make sure <span class="file">log4jdbc-1.1alpha1.jar</span> and the <span class="file">slf4j</span> jar files (v1.x) are in
|
||||
the classpath, as well as the jar file for the logging system that SLF4J forwards to and the jar file(s) for the actual
|
||||
jdbc driver that is being spied upon. Please refer the the <a href="http://www.slf4j.org/">SLF4J documentation</a>
|
||||
for information on setting up SLF4J. It's really easy!
|
||||
</p>
|
||||
</li>
|
||||
<li> <p> Set up your logging categories. There are 4 categories that are used by log4jdbc,
|
||||
If all 4 loggers are set to a level less than error (such as the FATAL level), then log4jdbc will not log
|
||||
anything, and in fact the actual (real) connection to the underlying database will be returned by the log4jdbc
|
||||
driver (thus allowing log4jdbc to be installed and available to turn on at runtime at a moment's notice,
|
||||
without imposing any actual performance loss when not being used). If any of the 4 logs are set to ERROR,INFO or
|
||||
DEBUG, then log4jdbc will be activated, wrapping and logging all activity in the jdbc connections returned by the
|
||||
underlying driver.</p>
|
||||
<pre>
|
||||
|
||||
Each of these logs can be set at either DEBUG, INFO or ERROR
|
||||
DEBUG includes the class name and line number (if available) at which the sql was executed.
|
||||
INFO includes the sql (or other information as applicable)
|
||||
ERROR will show the stack traces in the log output when sql exceptions occur.
|
||||
|
||||
jdbc.sqlonly shows only SQL in the log. SQL executed within a prepared statement is automatically shown with
|
||||
it's bind arguments replaced with the data bound at that position, for greatly increased readability.
|
||||
|
||||
jdbc.sqltiming shows the SQL, post-execution, including timing statistics on how long the sql took to execute.
|
||||
|
||||
jdbc.audit Logs ALL jdbc calls except for ResultSets. This is a very voluminous output, and is not normally
|
||||
needed unless tracking down a specific jdbc problem.
|
||||
|
||||
jdbc.resultset Even more voluminous, because all calls to ResultSet objects are logged.
|
||||
</pre>
|
||||
|
||||
<p>Additionally, there is one logger named log4jdbc.debug which is for use with internal debugging of log4jdbc.
|
||||
At this time it just prints out information on which underlying drivers were found and not found when the
|
||||
log4jdbc spy driver loads.</p>
|
||||
|
||||
<p>In a typical usage scenario, you might turn on only the jdbc.sqlonly logging at INFO level,
|
||||
just to view the sql coming out of your program.</p>
|
||||
|
||||
<p>Then if you wanted to view how long each sql statement is taking to execute, you might use jdbc.sqltiming.</p>
|
||||
|
||||
<p>jdbc.audit and jdbc.resultset are used for more in depth diagnosis of what is going on under the hood with jdbc
|
||||
as potentially almost every single call to jdbc could be logged (logs can grow very large, very quickly with this!)</p>
|
||||
|
||||
<p>SLF4J is a logging facade that can be used with many popular java logging systems. The setup for the logging
|
||||
categories will vary depending on which underlying logger you use. Sample configuration files for log4j are
|
||||
provided here: <a href="log4j.xml">log4j.xml</a> and <a href="log4j.properties">log4j.properties</a>.</p>
|
||||
</li>
|
||||
<li><p>Adjust debugging options. When logging at the DEBUG level, the class file and line number (if available) for the
|
||||
class that invoked jdbc is logged after each log statement. This is enormously useful for finding where in the
|
||||
code the SQL is generated. Be careful when using this on a production system because there is a small, but
|
||||
potentially significant penalty performance for generating this data on each logging statement.</p>
|
||||
|
||||
<p>In many cases, this call stack data is not very useful because the calling class into log4jdbc is a connection pool,
|
||||
object-persistance layer or other layer between log4jdbc and your application code-- but the class file and
|
||||
line number information you really are interested in seeing is where in your application the SQL was generated from.</p>
|
||||
|
||||
<p>Set the <code>log4jdbc.debug.stack.prefix</code> System property for log4jdc to help get around this problem:</p>
|
||||
|
||||
<p>
|
||||
(optional) <code>-Dlog4jdbc.debug.stack.prefix=<package.prefix></code> a String that is the partial (or full) package
|
||||
prefix for the package name of your application. The call stack will be searched down to the first occurence
|
||||
of a class that has the matching prefix. If this is not set, the actual class that called into log4jdbc is used
|
||||
in the debug output (in many cases this will be a connection pool class)</p>
|
||||
<p>
|
||||
For example, setting a system property such as this: <code>-Dlog4jdbc.debug.stack.prefix=com.mycompany.myapp</code>
|
||||
Would cause the call stack to be searched for the first call that came from code in the com.mycompany.myapp package or below,
|
||||
thus if all of your sql generating code was in code located in the com.mycompany.myapp package or any subpackages,
|
||||
this would be printed in the debug information, rather than the package name for a connection pool, object relational system, etc.
|
||||
</p>
|
||||
</li>
|
||||
<li>With the 1.1 alpha 1 release, a new tool is included which you can use to post-process sql timing logs produced by log4jdbc
|
||||
to produce simple profiling reports with statistics and a dump of the sql statements that ran the slowest within the log.
|
||||
To invoke the tool, use the profsql.sh (for unix/linux) and profsql.cmd (for windows) scripts located in the scripts
|
||||
folder. These scripts take as one argument, the filename of a sql timing log (generated from the
|
||||
<code>jdbc.sqltiming</code> log category. They produce a profiling report to stdout.
|
||||
At this point the tool is experimental and I expect it to evolve quite a bit over the next few releases.
|
||||
Nevertheless, it has already been very useful to me for tracking down SQL performance problems.
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<p class="right"><a href="#top">[back to top]</a></p>
|
||||
|
||||
<h2><a name="license"/>license</h2>
|
||||
<p>
|
||||
log4jdbc is open source software, licensed under the <b>Apache 2.0 license:</b> <a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>
|
||||
</p>
|
||||
|
||||
<p class="right"><a href="#top">[back to top]</a></p>
|
||||
<h2><a name="feedback"/>feedback</h2>
|
||||
|
||||
<p>Feedback and suggestions would be greatly appreciated. Email me at arthur_blake at users.sourceforge.net</p>
|
||||
|
||||
<p class="right"><a href="#top">[back to top]</a></p>
|
||||
<h1>
|
||||
|
||||
<a href="http://sourceforge.net/project/showfiles.php?group_id=194500">download</a> |
|
||||
<a href="#news">news</a> |
|
||||
<a href="#features">features</a> |
|
||||
<a href="#usage">usage</a> |
|
||||
<a href="apidocs/net/sf/log4jdbc/package-summary.html">javadoc</a> |
|
||||
<a href="#license">license</a> |
|
||||
<a href="#feedback">feedback</a>
|
||||
<br>
|
||||
|
||||
<img class="logo" src="log4jdbc-logo-gray.png">
|
||||
|
||||
</h1>
|
||||
<p class="ad">
|
||||
YourKit is kindly supporting open source projects with its full-featured Java Profiler.
|
||||
YourKit, LLC is creator of innovative and intelligent tools for profiling
|
||||
Java and .NET applications. Take a look at YourKit's leading software products:
|
||||
<a href="http://www.yourkit.com/java/profiler/index.jsp">YourKit Java Profiler</a> and
|
||||
<a href="http://www.yourkit.com/.net/profiler/index.jsp">YourKit .NET Profiler</a>.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -30,6 +30,11 @@ log4j.additivity.jdbc.sqlonly=false
|
||||
log4j.logger.jdbc.sqltiming=DEBUG,sqltiming
|
||||
log4j.additivity.jdbc.sqltiming=false
|
||||
|
||||
! Log connection open/close events and connection number dump
|
||||
log4j.logger.jdbc.connection=FATAL,connection
|
||||
log4j.additivity.jdbc.connection=false
|
||||
|
||||
|
||||
! the appender used for the JDBC API layer call logging above, sql only
|
||||
log4j.appender.sql=org.apache.log4j.FileAppender
|
||||
log4j.appender.sql.File=./logs/sql.log
|
||||
@@ -50,3 +55,10 @@ log4j.appender.jdbc.File=./logs/jdbc.log
|
||||
log4j.appender.jdbc.Append=false
|
||||
log4j.appender.jdbc.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.jdbc.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n
|
||||
|
||||
! the appender used for the JDBC Connection open and close events
|
||||
log4j.appender.connection=org.apache.log4j.FileAppender
|
||||
log4j.appender.connection.File=./logs/connection.log
|
||||
log4j.appender.connection.Append=false
|
||||
log4j.appender.connection.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.connection.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n
|
||||
|
||||
+16
-3
@@ -37,15 +37,23 @@
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<appender name="jdbc-connection" class="org.apache.log4j.FileAppender">
|
||||
<param name="File" value="./logs/connection.log"/>
|
||||
<param name="Append" value="false"/>
|
||||
<layout class="org.apache.log4j.PatternLayout">
|
||||
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss.SSS} %m%n"/>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
<!--
|
||||
The Following 4 logs can be turned on and off while the server is running
|
||||
The Following 5 logs can be turned on and off while the server is running
|
||||
LIVE in order to trace the SQL and/or all JDBC coming out of the application.
|
||||
|
||||
To turn a log on, set the level value to INFO or DEBUG (to see class name and
|
||||
line number information in the log) The DEBUG setting is much more inefficient
|
||||
but the output is much more useful.
|
||||
|
||||
To turn off JDBC logging completely, you must set all 4 logs to a level higher
|
||||
To turn off JDBC logging completely, you must set all 5 logs to a level higher
|
||||
than ERROR (FATAL is suggested.)
|
||||
-->
|
||||
|
||||
@@ -75,7 +83,12 @@
|
||||
<level value="fatal"/>
|
||||
<appender-ref ref="jdbc-appender"/>
|
||||
</logger>
|
||||
|
||||
|
||||
<!-- log connection open/close events and dump of all open connection numbers -->
|
||||
<logger name="jdbc.connection" additivity="false">
|
||||
<level value="fatal"/>
|
||||
<appender-ref ref="connection-appender"/>
|
||||
</logger>
|
||||
|
||||
<!-- this log is for internal debugging of log4jdbc, itself -->
|
||||
<!-- debug logging for log4jdbc itself -->
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 996 B |
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
red in logo is #f06
|
||||
purple in logo is #ef39e9
|
||||
*/
|
||||
|
||||
.left {text-align:left;}
|
||||
.right{text-align:right;}
|
||||
.usage {text-align:left;}
|
||||
h1 {font-size:1em;color:#f06;background-color:#eee;display:block;padding:0.8em;}
|
||||
h2 {font-size:1.2em;color:#f06;background-color:#eee;display:block;height:2em;padding-top:0.8em;}
|
||||
a {text-decoration:none;}
|
||||
a:link {color: #f06;}
|
||||
a:visited {color: #f06;}
|
||||
p {padding:10px;}
|
||||
span.file {font-weight:bold;}
|
||||
ul {padding:10px;list-style:square}
|
||||
ol {padding:10px;list-style:decimal;}
|
||||
|
||||
ul li {margin-left:2em;padding:0.3em;}
|
||||
ol li {margin-left:2em;padding:0.3em;}
|
||||
|
||||
li p {margin-left:0;}
|
||||
|
||||
code,pre {color:navy;background-color:beige;font-size:11pt;}
|
||||
|
||||
pre {border:2px dashed navy;margin-left:3em;margin-right:4em;margin-top:1em;margin-bottom:1em;white-space:pre-line;}
|
||||
|
||||
p.ad {font-size:1em;color:blue;}
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,5 @@
|
||||
To build log4jdbc, you must have Ant 1.6.5 or later installed,
|
||||
and JDK 1.4 and JDK 1.6 installed.
|
||||
|
||||
The build.cmd file is useful for building both the jdbc 3 version (JDK 1.4) and the jdbc 4 version (under JDK 1.6) under windows.
|
||||
The javadoc.cmd file is useful for building javadoc (requires the 3rd party ydoc tool)
|
||||
@@ -0,0 +1,19 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
REM invoke the 1.4 and the 1.6 jvm each in turn
|
||||
REM for JDBC 3 and JDBC 4 versions respectively
|
||||
|
||||
set ANT_HOME=c:\apache-ant-1.6.5
|
||||
|
||||
set JAVA_HOME=C:\jdk\1.4.2_18
|
||||
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
|
||||
|
||||
call java -version
|
||||
call ant -Djdbc.level=3 -Djvm.ver=1.4 all
|
||||
|
||||
set JAVA_HOME=C:\jdk\1.6.0_11
|
||||
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
|
||||
|
||||
call java -version
|
||||
call ant -Djdbc.level=4 -Djvm.ver=1.6 all
|
||||
+130
-34
@@ -1,28 +1,76 @@
|
||||
<?xml version='1.0' encoding='ISO-8859-1' ?>
|
||||
|
||||
<!--
|
||||
|
||||
Ant build script for log4jdbc
|
||||
|
||||
Tested with Apache Ant version 1.6.5
|
||||
Tested with Apache Ant version 1.6.5 & 1.7
|
||||
|
||||
built with jdk 1.4.2_13 (for use with jdbc3)
|
||||
and/or jdk 1.6.0 (for use with jdbc4)
|
||||
|
||||
Copyright 2007-2009 Arthur Blake
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
built with jdk 1.4.2_13
|
||||
-->
|
||||
|
||||
<project name="log4jdbc" default="all" basedir="..">
|
||||
|
||||
<target name="all" depends="cleancompile,compile,cleanjar,jar"/>
|
||||
<!-- the jdbc.level flag should be set externally to either 3 or 4
|
||||
|
||||
this is the jdbc version and should be 3 if using a jdk 1.4 or 1.5
|
||||
|
||||
the jdbc.level flag should be set to 4 if using a jdk 1.6 or greater.
|
||||
|
||||
defaults to jdbc3 build if not set externally
|
||||
|
||||
therefore to build both, ant should be invoked twice, setting the jdbc.level externally
|
||||
to 3 and then 4. and using the jdk 1.4 and then 1.6.
|
||||
-->
|
||||
|
||||
<property name="jdbc.level" value="3" />
|
||||
<property name="jvm.ver" value="1.4" />
|
||||
<property name="jdbc.prefix" value="jdbc${jdbc.level}" />
|
||||
|
||||
<property name="src" value="src-${jdbc.prefix}" />
|
||||
<property name="classes" value="classes-${jdbc.prefix}" />
|
||||
<property name="apidocs" value="doc/apidocs-${jdbc.prefix}" />
|
||||
|
||||
|
||||
<!-- release version -->
|
||||
<property name="version" value="1.1alpha1"/>
|
||||
<property name="version" value="1.2alpha2"/>
|
||||
|
||||
<!-- ydoc.home is only used for ydoc target for producing javadoc with generated UML
|
||||
requires the NON-FREE ydoc utility
|
||||
(use the javadoc target to generate regular javadoc)
|
||||
<target name="all" depends="cleancompile,compile,cleanjar,jar"/>
|
||||
|
||||
<!--
|
||||
The ydoc.home.3 and ydoc.home.4 properties are only used for the ydoc.3
|
||||
and ydoc.4 targets for producing javadoc with UML
|
||||
|
||||
it requires the commercial ydoc utility
|
||||
(see http://www.yworks.com/en/products_ydoc.htm)
|
||||
|
||||
use the javadoc target to generate regular javadoc
|
||||
|
||||
ydoc.home.3 is for jdk1.4 / JDBC 3
|
||||
ydoc.home.4 is for jdk1.6 / JDBC 4
|
||||
-->
|
||||
<property name="ydoc.home" value="/ydoc-2.2_04"/>
|
||||
<property name="ydoc.home.3" value="/ydoc-2.2_04"/>
|
||||
<property name="ydoc.home.4" value="/ydoc-2.2_04-jdk1.5"/>
|
||||
|
||||
<target name="compile" description="compile all the source code">
|
||||
<javac srcdir="src" destdir="classes" deprecation="true" debug="true">
|
||||
<javac source="${jvm.ver}" target="${jvm.ver}" srcdir="${src}" destdir="${classes}"
|
||||
deprecation="true" debug="true">
|
||||
<classpath>
|
||||
<pathelement location="$src"/>
|
||||
<fileset dir="lib">
|
||||
@@ -33,23 +81,23 @@
|
||||
</target>
|
||||
|
||||
<target name="cleancompile" description="delete all the .class files.">
|
||||
<delete dir="classes"/>
|
||||
<mkdir dir="classes"/>
|
||||
<delete dir="${classes}"/>
|
||||
<mkdir dir="${classes}"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="jar" description="jar up all the class files">
|
||||
<mkdir dir="build"/>
|
||||
<jar jarfile="build/log4jdbc-${version}.jar" basedir="classes"/>
|
||||
<jar jarfile="build/log4${jdbc.prefix}-${version}.jar" basedir="${classes}"/>
|
||||
</target>
|
||||
|
||||
<target name="cleanjar" description="delete the jar file">
|
||||
<delete file="build/log4jdbc-${version}.jar" description="delete the jar file"/>
|
||||
<delete file="build/log4${jdbc.prefix}-${version}.jar" description="delete the jar file"/>
|
||||
</target>
|
||||
|
||||
|
||||
<target name="cleanjavadoc">
|
||||
<delete dir="doc/apidocs" />
|
||||
<mkdir dir="doc/apidocs" />
|
||||
<delete dir="${apidocs}" />
|
||||
<mkdir dir="${apidocs}" />
|
||||
</target>
|
||||
|
||||
<target name="cleanrelease">
|
||||
@@ -58,12 +106,12 @@
|
||||
<delete file="../log4jdbc-${version}.tar.gz"/>
|
||||
</target>
|
||||
|
||||
<target name="release" depends="cleanrelease,all,ydoc" description="make a complete release distribution (a .jar zip and tar.gz file for release)">
|
||||
<target name="release" depends="cleanrelease" description="make a complete release distribution (a .jar zip and tar.gz file for release)">
|
||||
<zip destfile="../log4jdbc-${version}.zip">
|
||||
<zipfileset dir="." prefix="log4jdbc-${version}" excludes="*.zip,*.tar.gz,*,iml,*.ipr,*.iws,thirdparty-stuff/**,classes/**"/>
|
||||
<zipfileset dir="." prefix="log4jdbc-${version}" excludes="*.zip,*.tar.gz,*,iml,*.ipr,*.iws,thirdparty-stuff/**,classes*/**"/>
|
||||
</zip>
|
||||
<tar destfile="../log4jdbc-${version}.tar">
|
||||
<tarfileset dir="." prefix="log4jdbc-${version}" excludes="*.zip,*.tar.gz,*,iml,*.ipr,*.iws,thirdparty-stuff/**,classes/**"/>
|
||||
<tarfileset dir="." prefix="log4jdbc-${version}" excludes="*.zip,*.tar.gz,*,iml,*.ipr,*.iws,thirdparty-stuff/**,classes*/**"/>
|
||||
</tar>
|
||||
<gzip destfile="../log4jdbc-${version}.tar.gz" src="../log4jdbc-${version}.tar"/>
|
||||
<delete file="../log4jdbc-${version}.tar"/>
|
||||
@@ -72,11 +120,11 @@
|
||||
<!-- make the javadoc (or ydoc which includes UML diagrams) -->
|
||||
|
||||
<target name="javadoc" description="generate the javadoc" depends="cleanjavadoc">
|
||||
<delete dir="doc/apidocs" />
|
||||
<mkdir dir="doc/apidocs" />
|
||||
<javadoc destdir="doc/apidocs" packagenames="net.sf.log4jdbc.*"
|
||||
Windowtitle="log4jdbc ${version}"
|
||||
Header="<b><a href="http://log4jdbc.sourceforge.net">log4jdbc ${version}</a></b>"
|
||||
<delete dir="${apidocs}" />
|
||||
<mkdir dir="${apidocs}" />
|
||||
<javadoc destdir="${apidocs}" packagenames="net.sf.log4jdbc.*"
|
||||
Windowtitle="log4${jdbc.prefix} ${version}"
|
||||
Header="<b><a href="http://log4jdbc.sourceforge.net">log4${jdbc.prefix} ${version}</a></b>"
|
||||
Use="true" breakiterator="true">
|
||||
<classpath>
|
||||
<pathelement location="$src"/>
|
||||
@@ -84,24 +132,26 @@
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
</classpath>
|
||||
<sourcepath path="src"/>
|
||||
<sourcepath path="${src}"/>
|
||||
|
||||
<!-- note that the jdk source code is referenced here so that javadoc will be generated from
|
||||
interface class methods when none is specified in the implementation -->
|
||||
<!--
|
||||
<sourcepath path="/j2sdk1.4.2_13/src"/>
|
||||
<link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
|
||||
<link href="http://java.sun.com/j2ee/1.4/docs/api/"/>
|
||||
<link href="http://www.slf4j.org/api/"/>
|
||||
-->
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
<target name="ydoc" description="create javadoc using ydoc doclet to include UML diagrams" depends="cleanjavadoc">
|
||||
<target name="ydoc.3" description="(jdk1.4/JDBC3 version) create javadoc using ydoc doclet to include UML diagrams" depends="cleanjavadoc">
|
||||
|
||||
<property name="ps" value="${path.separator}"/>
|
||||
<property name="ps" value="${path.separator}" />
|
||||
|
||||
<javadoc destdir="doc/apidocs" packagenames="net.sf.log4jdbc.*"
|
||||
Windowtitle="log4jdbc ${version}"
|
||||
Header="<b><a href="http://log4jdbc.sourceforge.net">log4jdbc ${version}</a></b>"
|
||||
<javadoc destdir="${apidocs}" packagenames="net.sf.log4jdbc.*"
|
||||
Windowtitle="log4${jdbc.prefix} ${version}"
|
||||
Header="<b><a href="http://log4jdbc.sourceforge.net">log4${jdbc.prefix} ${version}</a></b>"
|
||||
Use="true" breakiterator="true">
|
||||
<classpath>
|
||||
<pathelement location="$src"/>
|
||||
@@ -109,22 +159,25 @@
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
</classpath>
|
||||
<sourcepath path="src"/>
|
||||
<sourcepath path="${src}"/>
|
||||
|
||||
<!-- note that the jdk source code is referenced here so that javadoc will be generated from
|
||||
interface class methods when none is specified in the implementation -->
|
||||
<sourcepath path="/j2sdk1.4.2_13/src"/>
|
||||
|
||||
<sourcepath path="/jdk/1.4.2_18/src"/>
|
||||
<link href="http://java.sun.com/j2se/1.4.2/docs/api/"/>
|
||||
<!--
|
||||
<link href="http://java.sun.com/j2ee/1.4/docs/api/"/>
|
||||
-->
|
||||
<link href="http://www.slf4j.org/api/"/>
|
||||
|
||||
<!-- ydoc doclet for UML diagrams, see http://www.yworks.com/en/products_ydoc.htm -->
|
||||
<doclet name="ydoc.doclets.YStandard"
|
||||
path="${ydoc.home}/lib/ydoc.jar${ps}${ydoc.home}/lib/class2svg.jar${ps}${ydoc.home}/resources${ps}${ydoc.home}/doc${ps}./classes">
|
||||
path="${ydoc.home.3}/lib/ydoc.jar${ps}${ydoc.home.3}/lib/class2svg.jar${ps}${ydoc.home.3}/resources${ps}${ydoc.home.3}/doc${ps}./${classes}">
|
||||
<param name="-author"/>
|
||||
<param name="-generic"/>
|
||||
<param name="-umlautogen"/>
|
||||
<param name="-filterpath" value="${ydoc.home}/lib/ydoc.jar"/>
|
||||
<param name="-filterpath" value="${ydoc.home.3}/lib/ydoc.jar"/>
|
||||
<param name="-filter" value="ydoc.filters.ExcludeFilter"/>
|
||||
<param name="-tag" value="y.precondition"/>
|
||||
<param name="-tag" value="y.postcondition"/>
|
||||
@@ -138,4 +191,47 @@
|
||||
</javadoc>
|
||||
</target>
|
||||
|
||||
<target name="ydoc.4" description="(jdk1.6/JDBC4 version) create javadoc using ydoc doclet to include UML diagrams" depends="cleanjavadoc">
|
||||
|
||||
<property name="ps" value="${path.separator}"/>
|
||||
|
||||
<javadoc destdir="${apidocs}" packagenames="net.sf.log4jdbc.*"
|
||||
maxmemory="512m"
|
||||
Windowtitle="log4${jdbc.prefix} ${version}"
|
||||
Header="<b><a href="http://log4jdbc.sourceforge.net">log4${jdbc.prefix} ${version}</a></b>"
|
||||
Use="true" breakiterator="true">
|
||||
<classpath>
|
||||
<pathelement location="$src"/>
|
||||
<fileset dir="lib">
|
||||
<include name="**/*.jar"/>
|
||||
</fileset>
|
||||
</classpath>
|
||||
<sourcepath path="${src}"/>
|
||||
|
||||
<!-- note that the jdk source code is referenced here so that javadoc will be generated from
|
||||
interface class methods when none is specified in the implementation -->
|
||||
|
||||
<sourcepath path="/jdk/1.6.0_11/src"/>
|
||||
<link href="http://java.sun.com/javase/6/docs/api/"/>
|
||||
<link href="http://www.slf4j.org/api/"/>
|
||||
|
||||
<!-- ydoc doclet for UML diagrams, see http://www.yworks.com/en/products_ydoc.htm -->
|
||||
<doclet name="ydoc.doclets.YStandard"
|
||||
path="${ydoc.home.4}/lib/ydoc.jar${ps}${ydoc.home.4}/lib/class2svg.jar${ps}${ydoc.home.4}/resources${ps}${ydoc.home.4}/doc${ps}./${classes}">
|
||||
<param name="-author"/>
|
||||
<param name="-generic"/>
|
||||
<param name="-umlautogen"/>
|
||||
<param name="-filterpath" value="${ydoc.home.4}/lib/ydoc.jar"/>
|
||||
<param name="-filter" value="ydoc.filters.ExcludeFilter"/>
|
||||
<param name="-tag" value="y.precondition"/>
|
||||
<param name="-tag" value="y.postcondition"/>
|
||||
<param name="-tag" value="y.complexity"/>
|
||||
<param name="-tag" value="param"/>
|
||||
<param name="-tag" value="return"/>
|
||||
<param name="-tag" value="see"/>
|
||||
<param name="-tag" value="y.uml"/>
|
||||
<param name="-linksource" value="true"/>
|
||||
</doclet>
|
||||
</javadoc>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
REM invoke the 1.4 and the 1.6 jvm each in turn
|
||||
REM for JDBC 3 and JDBC 4 versions respectively
|
||||
|
||||
set ANT_HOME=c:\apache-ant-1.6.5
|
||||
set ANT_OPTS=-Xmx512m
|
||||
|
||||
set JAVA_HOME=C:\jdk\1.4.2_18
|
||||
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
|
||||
|
||||
call java -version
|
||||
call ant -Djdbc.level=3 -Djvm.ver=1.4 ydoc.3
|
||||
|
||||
set JAVA_HOME=c:\jdk\1.6.0_11
|
||||
set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin
|
||||
|
||||
call java -version
|
||||
call ant -Djdbc.level=4 -Djvm.ver=1.6 ydoc.4
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
rem *************************************************************************************************
|
||||
rem * *
|
||||
rem * Copyright 2007 Arthur Blake *
|
||||
rem * Copyright 2007-2009 Arthur Blake *
|
||||
rem * *
|
||||
rem * Licensed under the Apache License, Version 2.0 (the "License"); *
|
||||
rem * you may not use this file except in compliance with the License. *
|
||||
@@ -25,4 +25,4 @@ rem * profiling output report.
|
||||
rem * *
|
||||
rem *************************************************************************************************
|
||||
|
||||
java -Xmx1024m -classpath ..\build\log4jdbc-1.1alpha1.jar net.sf.log4jdbc.PostLogProfilerProcessor %*
|
||||
java -Xmx1024m -classpath ..\build\log4jdbc3-1.2alpha2.jar net.sf.log4jdbc.PostLogProfilerProcessor %*
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
|
||||
# *************************************************************************************************
|
||||
# * *
|
||||
# * Copyright 2007 Arthur Blake *
|
||||
# * Copyright 2007-2009 Arthur Blake *
|
||||
# * *
|
||||
# * Licensed under the Apache License, Version 2.0 (the "License"); *
|
||||
# * you may not use this file except in compliance with the License. *
|
||||
@@ -25,4 +25,4 @@
|
||||
# * *
|
||||
# *************************************************************************************************
|
||||
|
||||
java -Xmx1024m -classpath ../build/log4jdbc-1.1alpha1.jar net.sf.log4jdbc.PostLogProfilerProcessor $@
|
||||
java -Xmx1024m -classpath ../build/log4jdbc3-1.2alpha2.jar net.sf.log4jdbc.PostLogProfilerProcessor $@
|
||||
|
||||
+13
-7
@@ -1,6 +1,5 @@
|
||||
/**
|
||||
*
|
||||
* Copyright 2007 Arthur Blake
|
||||
* Copyright 2007-2009 Arthur Blake
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -40,8 +39,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class CallableStatementSpy extends PreparedStatementSpy implements CallableStatement
|
||||
{
|
||||
private final SpyLogDelegator log;
|
||||
|
||||
protected void reportAllReturns(String methodCall, String msg)
|
||||
{
|
||||
log.methodReturned(this, methodCall, msg);
|
||||
@@ -53,7 +50,17 @@ public class CallableStatementSpy extends PreparedStatementSpy implements Callab
|
||||
private CallableStatement realCallableStatement;
|
||||
|
||||
/**
|
||||
* Create a CallableStatementSpy to spy upon a CallableStatement.
|
||||
* Get the real underlying CallableStatement that this CallableStatementSpy wraps.
|
||||
*
|
||||
* @return the real underlying CallableStatement.
|
||||
*/
|
||||
public CallableStatement getRealCallableStatement()
|
||||
{
|
||||
return realCallableStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a CallableStatementSpy (JDBC 3 version) to spy upon a CallableStatement.
|
||||
*
|
||||
* @param sql The SQL used for this CallableStatement
|
||||
* @param connectionSpy The ConnectionSpy which produced this CallableStatementSpy
|
||||
@@ -63,7 +70,6 @@ public class CallableStatementSpy extends PreparedStatementSpy implements Callab
|
||||
{
|
||||
super(sql, connectionSpy, realCallableStatement);
|
||||
this.realCallableStatement = realCallableStatement;
|
||||
log = SpyLogFactory.getSpyLogDelegator();
|
||||
}
|
||||
|
||||
public String getClassType()
|
||||
@@ -625,6 +631,7 @@ public class CallableStatementSpy extends PreparedStatementSpy implements Callab
|
||||
|
||||
public void setBytes(String parameterName, byte[] x) throws SQLException
|
||||
{
|
||||
//todo: dump byte array?
|
||||
String methodCall = "setBytes(" + parameterName + ", " + x + ")";
|
||||
try
|
||||
{
|
||||
@@ -1041,7 +1048,6 @@ public class CallableStatementSpy extends PreparedStatementSpy implements Callab
|
||||
reportException(methodCall, s);
|
||||
throw s;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void registerOutParameter(String parameterName, int sqlType, String typeName) throws SQLException
|
||||
+94
-7
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Copyright 2007 Arthur Blake
|
||||
* Copyright 2007-2009 Arthur Blake
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,21 +23,80 @@ import java.sql.SQLException;
|
||||
import java.sql.SQLWarning;
|
||||
import java.sql.Savepoint;
|
||||
import java.sql.Statement;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Wraps a JDBC Connection and reports method calls, returns and exceptions.
|
||||
*
|
||||
* This version is for jdbc 3.
|
||||
*
|
||||
* @author Arthur Blake
|
||||
*/
|
||||
public class ConnectionSpy implements Connection, Spy
|
||||
{
|
||||
private Connection realConnection;
|
||||
|
||||
/**
|
||||
* Get the real underlying Connection that this ConnectionSpy wraps.
|
||||
*
|
||||
* @return the real underlying Connection.
|
||||
*/
|
||||
public Connection getRealConnection()
|
||||
{
|
||||
return realConnection;
|
||||
}
|
||||
|
||||
private SpyLogDelegator log;
|
||||
|
||||
private int connectionNumber;
|
||||
private final Integer connectionNumber;
|
||||
private static int lastConnectionNumber = 0;
|
||||
private static final Object connectionNumberLock = new Object();
|
||||
|
||||
/**
|
||||
* Contains a Mapping of connectionNumber to currently open ConnectionSpy
|
||||
* objects.
|
||||
*/
|
||||
private static final Map connectionTracker = new HashMap();
|
||||
|
||||
/**
|
||||
* Get a dump of how many connections are open, and which connection numbers
|
||||
* are open.
|
||||
*
|
||||
* @return an open connection dump.
|
||||
*/
|
||||
public static String getOpenConnectionsDump()
|
||||
{
|
||||
StringBuffer dump = new StringBuffer();
|
||||
int size;
|
||||
Integer[] keysArr;
|
||||
synchronized (connectionTracker)
|
||||
{
|
||||
size = connectionTracker.size();
|
||||
if (size==0)
|
||||
{
|
||||
return "open connections: none";
|
||||
}
|
||||
Set keys = connectionTracker.keySet();
|
||||
keysArr = (Integer[]) keys.toArray(new Integer[keys.size()]);
|
||||
}
|
||||
|
||||
Arrays.sort(keysArr);
|
||||
|
||||
dump.append("open connections: ");
|
||||
for (int i=0; i < keysArr.length; i++)
|
||||
{
|
||||
dump.append(keysArr[i]);
|
||||
dump.append(" ");
|
||||
}
|
||||
|
||||
dump.append("(");
|
||||
dump.append(size);
|
||||
dump.append(")");
|
||||
return dump.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ConnectionSpy that wraps a given Connection.
|
||||
@@ -46,6 +105,22 @@ public class ConnectionSpy implements Connection, Spy
|
||||
*/
|
||||
public ConnectionSpy(Connection realConnection)
|
||||
{
|
||||
this(realConnection, DriverSpy.defaultRdbmsSpecifics);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new ConnectionSpy that wraps a given Connection.
|
||||
*
|
||||
* @param realConnection "real" Connection that this ConnectionSpy wraps.
|
||||
* @param rdbmsSpecifics the RdbmsSpecifics object for formatting logging appropriate for the Rdbms used.
|
||||
*/
|
||||
public ConnectionSpy(Connection realConnection, RdbmsSpecifics rdbmsSpecifics)
|
||||
{
|
||||
if (rdbmsSpecifics == null)
|
||||
{
|
||||
rdbmsSpecifics = DriverSpy.defaultRdbmsSpecifics;
|
||||
}
|
||||
setRdbmsSpecifics(rdbmsSpecifics);
|
||||
if (realConnection == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Must pass in a non null real Connection");
|
||||
@@ -53,10 +128,13 @@ public class ConnectionSpy implements Connection, Spy
|
||||
this.realConnection = realConnection;
|
||||
log = SpyLogFactory.getSpyLogDelegator();
|
||||
|
||||
synchronized (connectionNumberLock)
|
||||
synchronized (connectionTracker)
|
||||
{
|
||||
connectionNumber = ++lastConnectionNumber;
|
||||
connectionNumber = new Integer(++lastConnectionNumber);
|
||||
connectionTracker.put(connectionNumber, this);
|
||||
}
|
||||
log.connectionOpened(this);
|
||||
reportReturn("new Connection");
|
||||
}
|
||||
|
||||
private RdbmsSpecifics rdbmsSpecifics;
|
||||
@@ -81,7 +159,7 @@ public class ConnectionSpy implements Connection, Spy
|
||||
return rdbmsSpecifics;
|
||||
}
|
||||
|
||||
public int getConnectionNumber()
|
||||
public Integer getConnectionNumber()
|
||||
{
|
||||
return connectionNumber;
|
||||
}
|
||||
@@ -404,7 +482,7 @@ public class ConnectionSpy implements Connection, Spy
|
||||
String methodCall = "isReadOnly()";
|
||||
try
|
||||
{
|
||||
return realConnection.isReadOnly();
|
||||
return reportReturn(methodCall,realConnection.isReadOnly());
|
||||
}
|
||||
catch (SQLException s)
|
||||
{
|
||||
@@ -549,6 +627,7 @@ public class ConnectionSpy implements Connection, Spy
|
||||
|
||||
public void setTypeMap(java.util.Map map) throws SQLException
|
||||
{
|
||||
//todo: dump map?
|
||||
String methodCall = "setTypeMap(" + map + ")";
|
||||
try
|
||||
{
|
||||
@@ -661,6 +740,14 @@ public class ConnectionSpy implements Connection, Spy
|
||||
reportException(methodCall, s);
|
||||
throw s;
|
||||
}
|
||||
finally
|
||||
{
|
||||
synchronized (connectionTracker)
|
||||
{
|
||||
connectionTracker.remove(connectionNumber);
|
||||
}
|
||||
log.connectionClosed(this);
|
||||
}
|
||||
reportReturn(methodCall);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user