J2EE uses p6spy to view the SQL statements executed in the Java program, tomcat configuration

Source: Internet
Author: User

Today, I changed an old version of the system. Since it was a framework a few years ago, there are fewer people who know more about it, and debugging is a bit difficult. In a permission management system, there are many associated tables, and allCodeThe jar package has been created, and the source code cannot be found. The SQL statement cannot be viewed, but the cause should be a data error. You need to find the database table and link corresponding to the module to find out the problem.

You can use p6spy to search the Internet and output it in the console or log file.ProgramSQL Execution information, and simple configuration for the current simple requirements.

1. Download a p6spyinstall. jar file online. After decompression, you can find the spy. properties and p6spy. Jar files.

For tomcat5.5

Put spy. properties in the {tomcathome}/common/classes folder.
Put p6spy. jar is in the {tomcathome}/common/lib folder.

For Tomcat 6, put both files in the {tomcathome}/lib folder.

2. Modify the location of the data source or database connection defined in the program: Change the <drivername/> General Oracle should be as follows:

 
<Drivername> oracle. JDBC. Driver. oracledriver </drivername>

To:

 
<Drivername> com. p6spy. Engine. Spy. p6spydriver </drivername>

3. modify the configuration in the spy. properties file:

Change to realdriver = oracle. JDBC. Driver. oracledriver

The following parts are valid without a well number:

# Specifies the appender to use for logging
# Appender = com. p6spy. Engine. Logging. appender. log4jlogger // use log4j to output SQL
Appender = com. p6spy. Engine. Logging. appender. stdoutlogger // use the console to output
# Appender = com. p6spy. Engine. Logging. appender. filelogger // output to the log file. In addition, the default name of the output file is spy. log.

 

After the modification, restart the application to view all the executed SQL statements. For more detailed configuration, see:

Http://wenku.baidu.com/view/b68719126edb6f1aff001fb0.html

 

 

Related Article

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.