P6spy:
Http://www.p6spy.com/
An open source Java tool that intercepts and logs all database statements that use JDBC
Jdbc SQL profiler:
Http://sourceforge.net/projects/sqlprofiler/
Have you ever wondered which database indexes you shoshould create for your JDBC-based application? This swing-based SQL profiler tries to offer a tool to monitor which tables and columns are accessed the most in SQL queries to recommend index creation.
Irontrack SQL:
Http://www.irongrid.com/ironeyesql
Irontrack SQL increases the visibility of performance problems from build to build through time-based views of JDBC performance metrics. irontrack SQL easily enables Java performance tuning by displaying database usage over time, overlaying and comparing performance datasets, and embedding Performance Testing with no source code changes.
Refer:
Http://netfork.javaeye.com/blog/286789
Http://www.ibm.com/developerworks/cn/java/j-lo-p6spy/index.html
Basic steps:
1. Put the jar package p6spy. jar of p6spy into classpath. If it is a Web application, put it in yourwebapp/WEB-INF/lib/directory;
2, put the spy. properties in the classpath directory, if the web application in yourwebapp/WEB-INF/classess/directory, note that not lib/directory
3. Modify the default value of the driver program com. p6spy. Engine. Spy. p6spydriver in your application system;
4. Open the configuration file spy. properties, find the realdriver, and change its value to the real database driver name of your application system;
5. Run your application or web application in the bin directory of Tomcat. the log shows the detailed execution and Operation Records of the SQL statements monitored by p6spy, including the complete SQL Execution parameters.