jdbcGrabber is a thin JDBC wrapper similar to the defunct P6Spy wrapper. With it, you can wrap a vendor's JDBC wrapper in order to capture diagnostic information about what kind of SQL is being executed by your application.
The wrapper's pluggable architecture allows you to develop any kind of "sink" you like to process statements. Its original intention was to reverse engineer legacy applications inside corporations where documentation is scarce and the original developers are gone.
The primary design objective of this wrapper is to be as unobtrusive as possible. It does not use a single external library, so it won't interfere with the libraries your application uses. It can be configured to use a limited size processing queue that dumps out information is a separate thread so it won't slow down your application and won't consume too much memory. It does not modify the byte-code of your application in any way whatsoever.
Out-of-the box the wrapper comes with sinks to print SQL and the stack trace that called it to stdout or to capture it in a file. It also includes command line tools to parse the files and produce nice graphs that show which tables are called from which code branches.
Here is an example of the nice graph you can create with this tool:
There are several other JDBC wrappers out there, but I created another one for my use for several reasons:
In short, you replace your JDBC url and driver class with one that points to jdbcGrabber and the configuration file it should use. So, for example, instead of this:
You'd have this:
Then, in the "myconfig.properties" file you'd (among other things) specify the actual underlying JDBC url like this:
Then, in the same "myconfig.properties" file you'd specify how you want jdbcGrabber to behave and where you want it to write out results.
For a full description of how to use jdbcGrabber, check out the UserGuide