views:

543

answers:

3

I am looking for a tool that Logs SQL statemetns fired in the application as I use the application.

I found p6spy. But there is an issue with that. It doesnt seem to be compatible with XA Datasources.

Is there a way to make p6spy work on Websphere 6.1 OR is there an alternative to p6spy ?

Also, if anyone has any AspectJ code that intercepts the PreparedStatment object and dumps the SQL, that would also be great.

A: 

I seem to remember there being some parameter you can add to your jdbc url configuration, and/or the connection. Can't remember the details.

Michael Wiles
A: 

It does depend on the way that you are accessing the database. If you are using Hibernate then you can make that spit out its SQL, if you are accessing the datasource through WAS then you can use the trace service. Set the trace to something like:

=info: com.ibm.websphere.rsadapter.=detail

And see what you get out of it.

Michael Ransley
thanks Micahel for the info.
Sathya
A: 

It is not mandatory for the JDBC drivers to implement a feature to be able to extract / print out the SQL statements. To be honest, I would do this in database. All reasonable database products can log in detail everything that comes in. Also, you can at the same time get further information like execution plans and their impact on the server.