- 下载p6psy.jar以及spy.properties文件。
- 配置spy.properties如下:()
#################################################################
# P6Spy Options File #
# See documentation for detailed instructions #
##################################################################################################################################
# MODULES #
# #
# Modules provide the P6Spy functionality. If a module, such #
# as module_log is commented out, that functionality will not #
# be available. If it is not commented out (if it is active), #
# the functionality will be active. #
# #
# Values set in Modules cannot be reloaded using the #
# reloadproperties variable. Once they are loaded, they remain #
# in memory until the application is restarted. #
# #
#################################################################module.log=com.p6spy.engine.logging.P6LogFactory
#module.outage=com.p6spy.engine.outage.P6OutageFactory#################################################################
# REALDRIVER(s) #
# #
# In your application server configuration file you replace the #
# "real driver" name with com.p6spy.engine.spy.P6SpyDriver. This is #
# where you put the name of your real driver P6Spy can find and #
# register your real driver to do the database work. #
# #
# If your application uses several drivers specify them in #
# realdriver2, realdriver3. See the documentation for more #
# details. #
# #
# Values set in REALDRIVER(s) cannot be reloaded using the #
# reloadproperties variable. Once they are loaded, they remain #
# in memory until the application is restarted. #
# #
################################################################## oracle driver
# realdriver=oracle.jdbc.driver.OracleDriver# mysql Connector/J driver
# realdriver=com.mysql.jdbc.Driver# informix driver
# realdriver=com.informix.jdbc.IfxDriver# ibm db2 driver
# realdriver=COM.ibm.db2.jdbc.net.DB2Driver# the mysql open source driver
realdriver=com.mysql.jdbc.Driver#specifies another driver to use
realdriver2=
#specifies a third driver to use
realdriver3=
#the DriverManager class sequentially tries every driver that is
#registered to find the right driver. In some instances, it‘s possible to
#load up the realdriver before the p6spy driver, in which case your connections
#will not get wrapped as the realdriver will "steal" the connection before
#p6spy sees it. Set the following property to "true" to cause p6spy to
#explicitily deregister the realdrivers
deregisterdrivers=true################################################################
# P6LOG SPECIFIC PROPERTIES #
################################################################
# no properties currently available################################################################
# EXECUTION THRESHOLD PROPERTIES #
################################################################
# This feature applies to the standard logging of P6Spy. #
# While the standard logging logs out every statement #
# regardless of its execution time, this feature puts a time #
# condition on that logging. Only statements that have taken #
# longer than the time specified (in milliseconds) will be #
# logged. This way it is possible to see only statements that #
# have exceeded some high water mark. #
# This time is reloadable. #
#
# executionthreshold=integer time (milliseconds)
#
executionthreshold=################################################################
# P6OUTAGE SPECIFIC PROPERTIES #
################################################################
# Outage Detection
#
# This feature detects long-running statements that may be indicative of
# a database outage problem. If this feature is turned on, it will log any
# statement that surpasses the configurable time boundary during its execution.
# When this feature is enabled, no other statements are logged except the long
# running statements. The interval property is the boundary time set in seconds.
# For example, if this is set to 2, then any statement requiring at least 2
# seconds will be logged. Note that the same statement will continue to be logged
# for as long as it executes. So if the interval is set to 2, and the query takes
# 11 seconds, it will be logged 5 times (at the 2, 4, 6, 8, 10 second intervals).
#
# outagedetection=true|false
# outagedetectioninterval=integer time (seconds)
#
outagedetection=false
outagedetectioninterval=################################################################
# COMMON PROPERTIES #
################################################################# filter what is logged
filter=false# comma separated list of tables to include when filtering
include =
# comma separated list of tables to exclude when filtering
exclude =# sql expression to evaluate if using regex filtering
sqlexpression =
# turn on tracing
autoflush = true# sets the date format using Java‘s SimpleDateFormat routine
dateformat=#list of categories to explicitly include
includecategories=#list of categories to exclude: error, info, batch, debug, statement,
#commit, rollback and result are valid values
excludecategories=info,debug,result,batch
#allows you to use a regex engine or your own matching engine to determine
#which statements to log
#
#stringmatcher=com.p6spy.engine.common.GnuRegexMatcher
#stringmatcher=com.p6spy.engine.common.JakartaRegexMatcher
stringmatcher=# prints a stack trace for every statement logged
stacktrace=false
# if stacktrace=true, specifies the stack trace to print
stacktraceclass=# determines if property file should be reloaded
reloadproperties=false
# determines how often should be reloaded in seconds
reloadpropertiesinterval=60#if=true then url must be prefixed with p6spy:
useprefix=false#specifies the appender to use for logging
#appender=com.p6spy.engine.logging.appender.Log4jLogger
#appender=com.p6spy.engine.logging.appender.StdoutLogger
appender=com.p6spy.engine.logging.appender.FileLogger# name of logfile to use, note Windows users should make sure to use forward slashes in their pathname (e:/test/spy.log) (used for file logger only)
logfile = D:/spy.log# append to the p6spy log file. if this is set to false the
# log file is truncated every time. (file logger only)
append=false#The following are for log4j logging only
log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=p6spy - %m%n#log4j.appender.CHAINSAW_CLIENT=org.apache.log4j.net.SocketAppender
#log4j.appender.CHAINSAW_CLIENT.RemoteHost=localhost
#log4j.appender.CHAINSAW_CLIENT.Port=4445
#log4j.appender.CHAINSAW_CLIENT.LocationInfo=truelog4j.logger.p6spy=INFO,STDOUT
#################################################################
# DataSource replacement #
# #
# Replace the real DataSource class in your application server #
# configuration with the name com.p6spy.engine.spy.P6DataSource,#
# then add the JNDI name and class name of the real #
# DataSource here #
# #
# Values set in this item cannot be reloaded using the #
# reloadproperties variable. Once it is loaded, it remains #
# in memory until the application is restarted. #
# #
#################################################################
#realdatasource=/RealMySqlDS
#realdatasourceclass=com.mysql.jdbc.jdbc2.optional.MysqlDataSource#################################################################
# DataSource properties #
# #
# If you are using the DataSource support to intercept calls #
# to a DataSource that requires properties for proper setup, #
# define those properties here. Use name value pairs, separate #
# the name and value with a semicolon, and separate the #
# pairs with commas. #
# #
# The example shown here is for mysql #
# #
#################################################################
#realdatasourceproperties=port;3306,serverName;ibmhost,databaseName;mydb
#################################################################
# JNDI DataSource lookup #
# #
# If you are using the DataSource support outside of an app #
# server, you will probably need to define the JNDI Context #
# environment. #
# #
# If the P6Spy code will be executing inside an app server then #
# do not use these properties, and the DataSource lookup will #
# use the naming context defined by the app server. #
# #
# The two standard elements of the naming environment are #
# jndicontextfactory and jndicontextproviderurl. If you need #
# additional elements, use the jndicontextcustom property. #
# You can define multiple properties in jndicontextcustom, #
# in name value pairs. Separate the name and value with a #
# semicolon, and separate the pairs with commas. #
# #
# The example shown here is for a standalone program running on #
# a machine that is also running JBoss, so the JDNI context #
# is configured for JBoss (3.0.4). #
# #
#################################################################
#jndicontextfactory=org.jnp.interfaces.NamingContextFactory
#jndicontextproviderurl=localhost:1099
#jndicontextcustom=java.naming.factory.url.pkgs;org.jboss.nameing:org.jnp.interfaces#jndicontextfactory=com.ibm.websphere.naming.WsnInitialContextFactory
#jndicontextproviderurl=iiop://localhost:900 - 把p6psy.jar以及spy.properties放在classpath里面,p6spy.jar放入lib目录,spy.properties文件放入classes目录。
- 配置dataSource。
<bean id="dataSource"
class="com.p6spy.engine.spy.P6DataSource" >
<constructor-arg>
<bean
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName"
value="com.mysql.jdbc.Driver" />
<property name="url" value="${Url}" />
<property name="username" value="${username}" />
<property name="password" ref="ddns_password" />
</bean>
</constructor-arg>
</bean>
- 参考网址http://blog.csdn.net/rznice/article/details/7044614
- 只能打印最后一条sql语句。
P6Spy和sping配合显示真正的SQL
时间: 2024-10-06 09:12:25
P6Spy和sping配合显示真正的SQL的相关文章
采用p6spy完整显示hibernate的SQL语句
虽然在hibernate中有show_sql选项,但是显示出来的语句大多类似 select * from xxx where value=? 但是有时候我们需要得到完整的SQL语句,怎么办呢?使用P6SPY就可以完成这个任务 p6spy是一个开源软件,它可以跟踪任何使用jdbc的应用产生的数据库操作.特别适合于监控ejb服务器产生的 sql statements.官方网址:http://www.p6spy.com/目前p6spy 适用的应用服务器包括jboss, atg, orion, jona
通过Log4j的DEBUG级别来显示mybatis的sql语句
为了更加方便调试sql语句,需要显示mybatis的sql语句. 网络上的一般方式都是通过log4j来实现,但是很多都有问题. 经过实验,以下代码能够保持正常:(只显示mybatis的sql语句的debug语句,其他的debug不显示) log4j.rootLogger = DEBUG,CONSOLE,LogFile,ErrorFile #注意这里需要改成DEBUG # 应用于控制台 log4j.appender.CONSOLE = org.apache.log
css奇特用法之 IMG添加背景图片配合显示--效果惊艳
IMG标签本身是显示图片的,但通过CSS可以再为其设置背景图片,让其和自身的图片配合来显示,最终的效果会让你惊叹.当然,这个发现来自于老外,所以代码马上与大家分享.再此之前,我也从来没有想到过这个思路,我想这种思路可以应用的地方相当多了. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
通过BurpSuite和sqlmap配合对dvwa进行sql注入测试和用户名密码暴力破解
0x1:工具和环境介绍 dvwa:渗透测试环境 BurpSuite:强大的WEB安全测试工具 sqlmap:强大的sql注入工具 以上工具和环境都在kali linux上安装和配置. 0x2:步骤说明 配置Burp Suite和浏览器. 这一步比较简单,主要是用来抓取用来sql注入的信息. 在Burp中设置proxy代理:127.0.0.1:8080,配置浏览器使用代理,这样浏览器的request信息就可以被Burp抓取了. 抓取登录信息 在Burp的Proxy界面可以抓取到浏览器访问的信息,如
android之ListView和adapter配合显示图片和文字列表
listView页面布局:layout/activity_main.xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_hei
sql不显示重复列
在报表里,基本上都可以把重复的资料不显示,在SQL里怎么才能做到如下情况呢? a 10 a 20 b 30 b 40 b 50 显示为: a 10 20 b 30 40 50 SQL 如下: create table #a (part varchar(10),price int) go insert into #a values('a',10) insert into #a values('a',20) insert into #a values('b',30) insert into #a v
sql server显示行号
-- 工具->-- 选项->-- 文本编辑器-> -- 所有语言->-- 常规-> -- 显示->-- 行号 sql server显示行号,布布扣,bubuko.com
sql不显示反复列
在报表里,基本上都能够把反复的资料不显示,在SQL里怎么才干做到例如以下情况呢? a 10 a 20 b 30 b 40 b 50 显示为: a 10 20 b 30 40 50 SQL 例如以下: create table #a (part varchar(10),price int) go insert into #a values('a',10) insert into #a values('a',20) insert into #a values('b',30) insert into
完整SQL分页存储过程(支持多表联接)
http://www.cnblogs.com/andiki/archive/2009/03/24/1420289.html Code/********************************************************* * 作 用:数据分页(完整SQL分页存储过程(支持多表联接))* 作 者:齐李平* 创建日期:2009-03-23* 使用说明: 1.单表调用方法:EXEC proc_DataPagination @tblName = 'ipa',@fldName