Hibernate SQL actual SQL statement monitoring-P6spy+hibernate+proxool settings

Source: Internet
Author: User

Because of the ORM tool, we debug the program is far from directly in the program to write a string of SQL simple, want to check a SQL is how happy, a line of sql = "SELECT * From ..." Look for it, now with Hibernate, Even if the show_sql=true is opened in JPA, it is a string called "name =?" and id =? "

Fortunately find a tool, P6spy, as a real JDBC agent, intercept all SQL, let us see a real SQL opportunity. Download First, the following configuration defaults to the same as my current project

Hibernate+proxool+postgresql the deployment level after the change is Hibernate+proxool+p6spy+postgresql

After the P6spy download, unpack the jar package, the steps are simple:

    1. The P6spy.jar is placed under the web-inf/lib of the Web program.
    2. Spy.properteis into the web-inf/classess.

Spy.properties to change the following properties:

Realdriver=org.postgresql. Driver   //True JDBC driver name deregisterdrivers=Trueappender= Com.p6spy.engine.logging.appender.StdoutLogger  //output to the console

Then change the configuration of Proxool connection pool, replace the real JDBC driver with P6spy, as an intermediary agent, intercept SQL

Proxool.properties

Jdbc-0.proxool.driver-class=com.p6spy.engine.spy.p6spydriver

The configuration is complete, open the IDE and admire the long-lost SQL statement.

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.