問題描述
Websphere 6.1 中的 SQL 日誌記錄 (SQL logging in Websphere 6.1)
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.
參考解法
方法 1:
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.
方法 2:
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.
方法 3:
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.
方法 4:
You shold change trace level into jdbc driver. If you using DB2 then change custom properties for data source if you using Oracle then change driver on the ojbdc6_g.jar and change JVM properties
(by Sathya、meh、Michael Wiles、mransley、Ravil)