- 浏览: 308334 次
- 性别:
- 来自: 深圳
文章分类
最新评论
-
lzz3717845:
有道理,受教了~谢谢
关于SQL中自动增长列值回复(还原)的问题 -
桃汁天天:
ExtJs中如何动态设置其选中状态!! -
sangumaolv2:
你TM在说什么啊。。。。
关于SQL中自动增长列值回复(还原)的问题 -
duyupeng:
你好,我最近也是在使用这个控件,只是用了_id、_parent ...
ExtJs 中的TreeGrid(Ext.ux.maximgb.tg.EditorGridPanel详解与其他问题解决办法) -
wokao_wg:
大伙可以看看作者说的http://www.sencha.com ...
ExtJs 中的TreeGrid(Ext.ux.maximgb.tg.EditorGridPanel详解与其他问题解决办法)2
P6Spy和sping配合显示真正的SQL
1,p6spy.jar放入lib目录,spy.properties文件放入classes目录
2,spy.properties文件做下面的配置之后,可以把sql语句打印到控制台和文件:
############################################################## # 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.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. # # # ############################################################## # the hsqldb open source driver #realdriver=org.hsqldb.jdbcDriver # 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=org.gjt.mm.mysql.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 # ############################################################## # comma separated list of tables to include include = # comma separated list of tables to exclude exclude = # sql expression to evaluate if using regex sqlexpression = # filter what is logged filter=false # turn on tracing trace = true 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= 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 = c:/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=true #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.F=org.apache.log4j.DailyRollingFileAppender log4j.appender.A2.DatePattern='.'yyyy-MM-dd log4j.appender.F.File=c:/spy.log log4j.appender.F.layout=org.apache.log4j.PatternLayout #log4j.appender.F.layout.ConversionPattern=%p %t %c - %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=true log4j.logger.p6spy=INFO,STDOUT,F ############################################################## # 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;myhost,databaseName;jbossdb,foo;bar ############################################################## # 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
3,修改Spring的context文件(本身引入了配置文件):
<!-- P6Spy Just for development--> <bean id="dataSource" class="com.p6spy.engine.spy.P6DataSource"> <constructor-arg> <bean class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="${jdbc.driverClassName}" /> <property name="url" value="${jdbc.url}" /> <property name="username" value="${jdbc.username}" /> <property name="password" value="${jdbc.password}" /> </bean> </constructor-arg> </bean>
- p6spy-install.zip (251.9 KB)
- 下载次数: 25
评论
1 楼
fandayrockworld
2013-01-11
用他打印处理出来的sql中的单引号,你是怎么处理的?
比如:
insert into ta(key,value) values('1','dddd'ddddd')
dddd'ddddd应该换成dddd\'ddddd ,这个sql才能执行,请问是怎么处理的?
比如:
insert into ta(key,value) values('1','dddd'ddddd')
dddd'ddddd应该换成dddd\'ddddd ,这个sql才能执行,请问是怎么处理的?
发表评论
-
P6Spy应用:Hibernate显示真正SQL(3)
2012-08-03 18:44 1237更改p6spy.jar中的以下文件即可控制FileLogger ... -
P6Spy应用:Hibernate显示真正SQL(2)
2012-08-03 18:14 1447下表列出了 spy.properties 配置文件 ... -
ResultSet用法集锦
2012-02-23 16:56 139743ResultSet用法集锦 结 ... -
ResultSet 参数設置使用實例
2012-02-23 14:32 1156public static String[][] ... -
可供参考的【数据库连接池(DBCP)】2
2012-02-10 12:01 1004import java.sql.Connection; ... -
可供参考的【数据库连接池(DBCP)】
2012-02-10 10:10 1019package com.spring.test; ... -
类型检查(RTTI与反射机制)转载
2012-02-02 10:35 1142... -
Servlet 3.0 新特性概览
2012-01-30 15:14 1005Se ... -
hibernate.hbm2ddl.auto配置详情
2011-12-09 11:02 1108hibernate.hbm2ddl.auto参数 ... -
如何在web.xml文件中引入其他的xml文件(web.xml如何拆分)
2011-11-14 20:08 8105如何在web.xm ... -
URL的Encoder、Decoder
2011-09-14 17:47 951URL : java.net.URLEncoder.e ... -
java中的DateAdd
2011-04-18 21:58 2347/** * 追溯到 startDate ... -
ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE
2011-04-18 21:52 2344Statement stmt = con.createSt ... -
都是空格惹得祸
2010-10-28 11:06 1158在一个属性文件中获取相关信息时:如 database.p ... -
SVN提交工作时需要注意的事项
2010-10-14 20:31 940一.提交之前先更新 1. ...
相关推荐
P6Spy是一个开源的JDBC代理库,它允许我们监控并记录应用通过JDBC执行的所有数据库操作,包括那些由Hibernate生成的SQL语句。它不仅可以提供完整的SQL语句,还能够提供执行时间、性能指标等详细信息,这对于优化...
1. **SQL日志记录**:P6Spy能够捕获并记录应用程序执行的所有SQL语句,包括参数值,这对于分析SQL性能和定位问题非常有价值。 2. **格式化输出**:P6Spy可以按照自定义的格式输出SQL日志,使其更易于阅读和分析。 ...
这篇博客“使用p6spy完整显示hibernate的SQL语句”可能详细解释了如何配置和使用p6spy来跟踪Hibernate生成并执行的SQL。 首先,`p6spy`是一个Java数据库代理库,它可以拦截并记录所有通过JDBC发送到数据库的SQL语句...
P6spy是一个JDBC Driver的包装工具,p6spy通过对JDBC Driver的封装以达到对SQL语句的监听和分析,以达到各种目的。 p6spy的安装步骤: 1. 下载p6spy的安装包 2. 把p6spy的jar包放到Classpath中,如果是WEB App...
1. **SQL日志记录**:P6Spy 可以捕获并记录应用程序执行的所有SQL语句,包括参数和执行时间,这对于调试和性能分析非常有用。 2. **格式化输出**:P6Spy 提供了自定义的日志格式,可以按照开发者的需求定制输出信息...
标题中提到的“输出完整SQL”,意味着P6Spy可以捕获并记录应用程序发出的所有SQL语句,包括参数。这对于调试和性能分析非常有用,特别是当SQL语句是动态生成或者使用了预编译的PreparedStatement时。 5. **兼容性*...
p6spy和sqlProfiler的配合使用让你的hibernate的show_sql更好用 p6spy和sqlProfiler的配合使用让你的hibernate的show_sql更好用 p6spy和sqlProfiler的配合使用让你的hibernate的show_sql更好用
p6spy 是一个开源的 Java 框架,它的主要功能是在不修改代码的情况下,监控和记录 Java 应用程序中执行的所有 SQL 语句。这个工具对于开发者来说非常有用,因为它可以帮助定位性能瓶颈,特别是在使用 ORM(对象关系...
内含p6spy-3.6.0.zip,p6spy最新Hibernate和Mybatis拦截并格式化sql配置.txt两个文件,用于调试监控项目运行状态,亲测可用,测试整理出来花了我很长时间的,好用不可多得!
**P6Spy** 是一个开源的Java库,用于监控和日志记录应用程序与数据库之间的所有交互。它通过拦截和包裹JDBC驱动程序来实现这一功能,使得开发人员和DBA可以详细跟踪SQL查询,这对于性能优化、问题排查以及理解应用...
专门用来监控hibernate的sql输出,进行调试应用程序的工具,找了好久才找到,里面有个配置文件,记住realdriver是你的驱动,而在hibernate设置的驱动是这个驱动代理,p6spy的驱动,相当于在hibernate和数据库之间放...
- **概述**:文档提到p6spy可以用于拦截Hibernate通过JDBC执行的SQL语句。Hibernate是一个流行的ORM框架,用于简化Java应用中的数据访问操作。 - **具体步骤**: 1. **替换数据库驱动**:正如前文所述,首先需要将...
p6spy是一个开源的Java库,设计用于监视和分析应用程序中执行的SQL语句。它的主要用途是在不修改代码的情况下,帮助开发者监控和调试应用程序与数据库之间的交互,尤其适用于那些使用ORM(对象关系映射)框架如...
p6spy支持jpa(如hibernate、ibatis/mybatis)打印完整sql。 此为本人在p6spy源码基础上进行修改,使其能在sql日志中过滤resultset,是sql更简洁,开发更方便。
# oracle driver # realdriver=oracle.jdbc.driver.OracleDriver # mysql Connector/J driver ... # informix driver ... # ibm db2 driver ...# the mysql open source driver realdriver=org.gjt.mm.mysql.Driver ...
与hibernate配合使用实现sql语句参数的打印及其他的一些性能方面的监控,有利于优化sql代码,用法上网随便一搜很多的
在企业做项目时如果用了hibernate会有个头疼问题,就是如何让输出sql方便查看,因为出了问题时,要去查错时sql日志会给我们很大帮助,但hibernate通过配p6spy输出很乱,且只能输了到spy.log中,很不好查看,这里是我...
IronTrack SQL是基于Apache许可证的开源工具,通过与开源JDBC驱动p6spy合作,提供了一个增强的对基于Hibernate的数据库应用的可视化调试和性能评测手段。 当开发者初次接触Hibernate时,他们通常会寻找方法来监控...
“工具”则可能指的是使用了一些第三方的SQL监控工具,如P6Spy,它是一个开源的Java库,可以用来监控和记录应用程序与数据库之间的所有交互。P6Spy能够拦截并记录所有的SQL语句,包括HQL转换后的结果,这对于数据库...