P6spy implements complete SQL log output

Source: Internet
Author: User
Although the show_ SQL option is available in hibernate, most of the displayed statements are similar.
Select * from XXX Where value =?
But sometimes we need a complete SQL statement. What should we do? You can use p6spy to complete this task.

P6spy is an open-source software that can trace any database operations generated by applications using JDBC. It is particularly suitable for monitoring the SQL statements generated by the EJB server.
Official Website: http://www.p6spy.com/
Currently, p6spy is applicable to JBoss, ATG, Orion, Jonas, Iplanet, WebLogic, websphere, resin and tomcat.

The following describes how to install p6spy on a tomcat application:
(1) download the zip package at http://www.p6spy.com/download.html
(2) decompress the p6spy. Jar spy. properties files.
(3) Put p6spy. jar into the WEB-INF/lib directory of the application, put spy. properties into the WEB-INF/classes directory
(4) Modify spy. Properties

Realdriver = com. MySQL. JDBC. DRIVER: remove the # above this line
Logfile = C:/spy. Log modify a log file name

(5) Modify hibernate. xml and set connection. driver_class to com. p6spy. Engine. Spy. p6spydriver.
(6) Restart Tomcat
(7) The spy. Log in C:/records the database access.

In fact, p6spy intercepts statment and preparedstatement to output SQL statements. JDBC can also output logs. You only need to set the driver to the driver provided by p6spy.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.