Using P6SPY with OC4J
P6Spy is an open source utility that you can use to log the SQL statements generated by J2EE containers. For details about about P6SPY please look at http://www.p6spy.com/. This blog entry will contain the instructions to configure P6SPY with OC4J 9.0.4.
Install P6SPY files in OC4J environment
Copy the p6spy.jar and spy.properties files to %OC4J_HOME%/j2ee/home/applib directory
Edit the file %OC4J_HOME%/j2ee/home/config/datasources.xml for the DataSource that is being used by your application and replace the line:
Edit the file %OC4J_HOME%/j2ee/home/applib/spy.properties and uncomment the line
Restart OC4J and run your J2EE application that contains CMP entity beans and the SQL statements generated by OC4J will be captured and logged in %OC4J_HOME%/j2ee/home/spy.log file.