- 浏览: 980934 次
文章分类
- 全部博客 (428)
- Hadoop (2)
- HBase (1)
- ELK (1)
- ActiveMQ (13)
- Kafka (5)
- Redis (14)
- Dubbo (1)
- Memcached (5)
- Netty (56)
- Mina (34)
- NIO (51)
- JUC (53)
- Spring (13)
- Mybatis (17)
- MySQL (21)
- JDBC (12)
- C3P0 (5)
- Tomcat (13)
- SLF4J-log4j (9)
- P6Spy (4)
- Quartz (12)
- Zabbix (7)
- JAVA (9)
- Linux (15)
- HTML (9)
- Lucene (0)
- JS (2)
- WebService (1)
- Maven (4)
- Oracle&MSSQL (14)
- iText (11)
- Development Tools (8)
- UTILS (4)
- LIFE (8)
最新评论
-
Donald_Draper:
Donald_Draper 写道刘落落cici 写道能给我发一 ...
DatagramChannelImpl 解析三(多播) -
Donald_Draper:
刘落落cici 写道能给我发一份这个类的源码吗Datagram ...
DatagramChannelImpl 解析三(多播) -
lyfyouyun:
请问楼主,执行消息发送的时候,报错:Transport sch ...
ActiveMQ连接工厂、连接详解 -
ezlhq:
关于 PollArrayWrapper 状态含义猜测:参考 S ...
WindowsSelectorImpl解析一(FdMap,PollArrayWrapper) -
flyfeifei66:
打算使用xmemcache作为memcache的客户端,由于x ...
Memcached分布式客户端(Xmemcached)
P6Spy官网:http://p6spy.github.io/p6spy/2.0/configandusage.html
P6Spy下载:http://sourceforge.net/projects/p6spy/files/
P6Spy介绍:http://www.open-open.com/lib/view/open1429863625385.html
配置sqlP6Spy配置信息说明:http://blog.csdn.net/z69183787/article/details/43453581
P6Spy和sping配合显示真正的SQL:http://blog.csdn.net/rznice/article/details/7044614
P6Spy源码分析,理解跟踪SQL的工作原理 :http://blog.csdn.net/sunyujia/article/details/2207027
测试实例:
测试结果:
八月 23, 2016 6:42:43 下午 com.mchange.v2.log.slf4j.Slf4jMLog$Slf4jMLogger$InfoLogger log
信息: MLog clients using slf4j logging.
八月 23, 2016 6:42:44 下午 com.mchange.v2.log.slf4j.Slf4jMLog$Slf4jMLogger$InfoLogger log
信息: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: =============driver:com.mysql.jdbc.Driver
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: =============url:jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: =============user:donald
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: =============password:123456
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: ========Init p6DSource end=============
八月 23, 2016 6:42:44 下午 com.mchange.v2.log.slf4j.Slf4jMLog$Slf4jMLogger$InfoLogger log
信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 2sigdn9i1ervxzto1pef0|64cd046, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 2sigdn9i1ervxzto1pef0|64cd046, idleConnectionTestPeriod -> 60, initialPoolSize -> 5, jdbcUrl -> jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 100, maxStatementsPerConnection -> 0, minPoolSize -> 5, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
p6spy - 2016-08-23 18:42:44 -0 [p6spy] INFO - 06:42:44,822|100|1|statement|INSERT INTO user(name,age)VALUES(?,?)|INSERT INTO user(name,age)VALUES('jack',23)
p6spy - 2016-08-23 18:42:44 -3 [p6spy] INFO - 06:42:44,826|104|2|statement|INSERT INTO user(name,age)VALUES(?,?)|INSERT INTO user(name,age)VALUES('jack',23)
p6spy - 2016-08-23 18:42:44 -22 [p6spy] INFO - 06:42:44,845|19|1|statement|INSERT INTO user(name,age)VALUES(?,?)|INSERT INTO user(name,age)VALUES('mark',67)
p6spy - 2016-08-23 18:42:44 -22 [p6spy] INFO - 06:42:44,845|19|2|statement|INSERT INTO user(name,age)VALUES(?,?)|INSERT INTO user(name,age)VALUES('mark',67)
p6spy - 2016-08-23 18:42:44 -23 [p6spy] INFO - 06:42:44,846|0|1|statement|UPDATE user SET name = ?,age=? WHERE id=?|UPDATE user SET name = 'donald',age=28 WHERE id=11
p6spy - 2016-08-23 18:42:44 -23 [p6spy] INFO - 06:42:44,846|0|2|statement|UPDATE user SET name = ?,age=? WHERE id=?|UPDATE user SET name = 'donald',age=28 WHERE id=11
c3p0.properties文件配置:
driver=com.mysql.jdbc.Driver
url=jdbc\:mysql\://localhost\:3306/test?useUnicode\=true&characterEncoding\=utf8&characterSetResults\=utf8
user=donald
password=123456
minPoolSize=10
maxPoolSize=100
maxIdleTime=1800
acquireIncrement=3
maxStatements=1000
initialPoolSize=10
idleConnectionTestPeriod=60
acquireRetryAttempts=30
breakAfterAcquireFailure=true
testConnectionOnCheckout=false
spy.properties主要配置:
module.log=com.p6spy.engine.logging.P6LogFactory
realdriver=com.mysql.jdbc.Driver
deregisterdrivers=true
dateformat=hh:mm:ss,SSS
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 = 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 - %d{yyyy-MM-dd HH\:mm\:ss} -%-4r [%c] %-5p %x - %m%n
log4j.appender.ROLLFILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ROLLFILE.File=F:/spy-logs/
log4j.appender.ROLLFILE.DatePattern=yyyy-MM-dd'.log'
log4j.appender.ROLLFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLFILE.layout.ConversionPattern=p6spy - %d{yyyy-MM-dd HH\:mm\:ss} %5p %c{1}\:%L \: %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,ROLLFILE
log4j.properties配置:
log4j.rootLogger=INFO,CONSOLE,FILE
log4j.addivity.org.apache=false
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} -%-4r [%c] %-5p %x - %m%n
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.Encoding=gbk
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.File=F:/logs/
log4j.appender.FILE.DatePattern=yyyy-MM-dd'.log'
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[FH_sys] %d{yyyy-MM-dd HH\:mm\:ss} %5p %c{1}\:%L \: %m%n
问题结局:
1.driver com.mysql.jdbc.Driver is a real driver in spy.properties,
but it has been loaded before p6spy. p6spy will not wrap these connections.
Either prevent the driver from loading, or try setting 'deregisterdrivers' to true in spy.properties
方法:
#防止realdriver在p6spy驱动之前加载
deregisterdrivers=true
2.Connections could not be acquired from the underlying database
这个问题由于数据源配置问题
方法:
1,驱动配置有误:driver=com.mysql.jdbc.Driver
2,数据库连接地址有误:url=jdbc:mysql://localhost:3306/test?3useUnicode=true&characterEncoding=utf8
3,密码或帐号有误:username=donald password=123456
4,数据库未启动或无权访问
5,项目未引入对应的驱动jar包mysql-connector-java-5.1.8.jar
6,mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下:
进入mysql数据库:
grant all privileges on *.* to 'donald'@'%' identified by '123456';
flush privileges;
如果上面没有解决,看看c3p0.properties属性配置是不是有错
属性后面不要有空格
P6Spy下载:http://sourceforge.net/projects/p6spy/files/
P6Spy介绍:http://www.open-open.com/lib/view/open1429863625385.html
配置sqlP6Spy配置信息说明:http://blog.csdn.net/z69183787/article/details/43453581
P6Spy和sping配合显示真正的SQL:http://blog.csdn.net/rznice/article/details/7044614
P6Spy源码分析,理解跟踪SQL的工作原理 :http://blog.csdn.net/sunyujia/article/details/2207027
测试实例:
package p6spy; import java.beans.PropertyVetoException; import java.io.IOException; import java.io.InputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Properties; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.mchange.v2.c3p0.ComboPooledDataSource; import com.p6spy.engine.spy.P6DataSource; public class testP6Spy { private static Logger log = LoggerFactory.getLogger(testP6Spy.class); private static P6DataSource p6DSource =null; private static ComboPooledDataSource cpDSource =null; private static void initP6SpyDataSource(){ Properties props = new Properties(); InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("c3p0.properties"); try { props.load(in); } catch (IOException e) { e.printStackTrace(); } finally{ try { in.close(); } catch (IOException e) { e.printStackTrace(); } } cpDSource = new ComboPooledDataSource(); try { cpDSource.setDriverClass(props.getProperty("driver")); log.info("=============driver:"+props.getProperty("driver")); cpDSource.setJdbcUrl(props.getProperty("url")); log.info("=============url:"+props.getProperty("url")); cpDSource.setUser(props.getProperty("user")); log.info("=============user:"+props.getProperty("user")); cpDSource.setPassword(props.getProperty("password")); log.info("=============password:"+props.getProperty("password")); cpDSource.setInitialPoolSize(5); cpDSource.setMinPoolSize(30); cpDSource.setMinPoolSize(5); /*c3p0全局的PreparedStatements缓存的大小。 如果maxStatements与maxStatementsPerConnection均为0,则缓存不生效, 只要有一个不为0,则语句的缓存就能生效。如果默认值: 0*/ cpDSource.setMaxStatements(100); //最大空闲时间,60秒内未使用则连接被丢弃。若为0则永不丢弃。默认值: 0 cpDSource.setIdleConnectionTestPeriod(60); /*如果为false,则获取连接失败将会引起所有等待连接池来获取连接的线程抛出异常, 但是数据源仍有效保留,并在下次调用getConnection()的时候继续尝试获取连接。 如果设为true,那么在尝试获取连接失败后该数据源将申明已断开并永久关闭。默认: false*/ cpDSource.setBreakAfterAcquireFailure(false); //定义在从数据库获取新连接失败后重复尝试的次数。默认值: 30 ;小于等于0表示无限次 cpDSource.setAcquireRetryAttempts(30); cpDSource.setTestConnectionOnCheckout(false); } catch (PropertyVetoException e) { e.printStackTrace(); } p6DSource = new P6DataSource(cpDSource); log.info("========Init p6DSource end============="); } public static void main(String[] args){ initP6SpyDataSource(); testP6SpyBaseMysql(); } public static void testP6SpyBaseMysql() { Connection con = null;// 创建一个数据库连接 PreparedStatement pre = null;// 创建预编译语句对象,一般都是用这个而不用Statement ResultSet result = null;// 创建一个结果集对象 try { con = p6DSource.getConnection(); String iSql = "INSERT INTO user(name,age)VALUES(?,?)"; PreparedStatement ps =con.prepareStatement(iSql); ps.setString(1, "jack"); ps.setInt(2, 23); ps.execute(); ps.setString(1, "mark"); ps.setInt(2, 67); ps.execute(); String uSql = "UPDATE user SET name = ?,age=? WHERE id=?"; ps = con.prepareStatement(uSql); ps.setString(1, "donald"); ps.setInt(2, 28); ps.setInt(3, 11); ps.executeUpdate(); } catch (Exception e) { log.error("============ERROR:"+e.getMessage()); e.printStackTrace(); } finally { try { if (result != null) result.close(); if (pre != null) pre.close(); if (con != null) con.close(); } catch (Exception e) { e.printStackTrace(); } } } }
测试结果:
八月 23, 2016 6:42:43 下午 com.mchange.v2.log.slf4j.Slf4jMLog$Slf4jMLogger$InfoLogger log
信息: MLog clients using slf4j logging.
八月 23, 2016 6:42:44 下午 com.mchange.v2.log.slf4j.Slf4jMLog$Slf4jMLogger$InfoLogger log
信息: Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: =============driver:com.mysql.jdbc.Driver
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: =============url:jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: =============user:donald
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: =============password:123456
八月 23, 2016 6:42:44 下午 p6spy.testP6Spy initP6SpyDataSource
信息: ========Init p6DSource end=============
八月 23, 2016 6:42:44 下午 com.mchange.v2.log.slf4j.Slf4jMLog$Slf4jMLogger$InfoLogger log
信息: Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 3, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 2sigdn9i1ervxzto1pef0|64cd046, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 2sigdn9i1ervxzto1pef0|64cd046, idleConnectionTestPeriod -> 60, initialPoolSize -> 5, jdbcUrl -> jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 15, maxStatements -> 100, maxStatementsPerConnection -> 0, minPoolSize -> 5, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> false, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
p6spy - 2016-08-23 18:42:44 -0 [p6spy] INFO - 06:42:44,822|100|1|statement|INSERT INTO user(name,age)VALUES(?,?)|INSERT INTO user(name,age)VALUES('jack',23)
p6spy - 2016-08-23 18:42:44 -3 [p6spy] INFO - 06:42:44,826|104|2|statement|INSERT INTO user(name,age)VALUES(?,?)|INSERT INTO user(name,age)VALUES('jack',23)
p6spy - 2016-08-23 18:42:44 -22 [p6spy] INFO - 06:42:44,845|19|1|statement|INSERT INTO user(name,age)VALUES(?,?)|INSERT INTO user(name,age)VALUES('mark',67)
p6spy - 2016-08-23 18:42:44 -22 [p6spy] INFO - 06:42:44,845|19|2|statement|INSERT INTO user(name,age)VALUES(?,?)|INSERT INTO user(name,age)VALUES('mark',67)
p6spy - 2016-08-23 18:42:44 -23 [p6spy] INFO - 06:42:44,846|0|1|statement|UPDATE user SET name = ?,age=? WHERE id=?|UPDATE user SET name = 'donald',age=28 WHERE id=11
p6spy - 2016-08-23 18:42:44 -23 [p6spy] INFO - 06:42:44,846|0|2|statement|UPDATE user SET name = ?,age=? WHERE id=?|UPDATE user SET name = 'donald',age=28 WHERE id=11
c3p0.properties文件配置:
driver=com.mysql.jdbc.Driver
url=jdbc\:mysql\://localhost\:3306/test?useUnicode\=true&characterEncoding\=utf8&characterSetResults\=utf8
user=donald
password=123456
minPoolSize=10
maxPoolSize=100
maxIdleTime=1800
acquireIncrement=3
maxStatements=1000
initialPoolSize=10
idleConnectionTestPeriod=60
acquireRetryAttempts=30
breakAfterAcquireFailure=true
testConnectionOnCheckout=false
spy.properties主要配置:
module.log=com.p6spy.engine.logging.P6LogFactory
realdriver=com.mysql.jdbc.Driver
deregisterdrivers=true
dateformat=hh:mm:ss,SSS
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 = 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 - %d{yyyy-MM-dd HH\:mm\:ss} -%-4r [%c] %-5p %x - %m%n
log4j.appender.ROLLFILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ROLLFILE.File=F:/spy-logs/
log4j.appender.ROLLFILE.DatePattern=yyyy-MM-dd'.log'
log4j.appender.ROLLFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.ROLLFILE.layout.ConversionPattern=p6spy - %d{yyyy-MM-dd HH\:mm\:ss} %5p %c{1}\:%L \: %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,ROLLFILE
log4j.properties配置:
log4j.rootLogger=INFO,CONSOLE,FILE
log4j.addivity.org.apache=false
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH\:mm\:ss} -%-4r [%c] %-5p %x - %m%n
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.Encoding=gbk
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE=org.apache.log4j.DailyRollingFileAppender
log4j.appender.FILE.File=F:/logs/
log4j.appender.FILE.DatePattern=yyyy-MM-dd'.log'
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[FH_sys] %d{yyyy-MM-dd HH\:mm\:ss} %5p %c{1}\:%L \: %m%n
问题结局:
1.driver com.mysql.jdbc.Driver is a real driver in spy.properties,
but it has been loaded before p6spy. p6spy will not wrap these connections.
Either prevent the driver from loading, or try setting 'deregisterdrivers' to true in spy.properties
方法:
#防止realdriver在p6spy驱动之前加载
deregisterdrivers=true
2.Connections could not be acquired from the underlying database
这个问题由于数据源配置问题
方法:
1,驱动配置有误:driver=com.mysql.jdbc.Driver
2,数据库连接地址有误:url=jdbc:mysql://localhost:3306/test?3useUnicode=true&characterEncoding=utf8
3,密码或帐号有误:username=donald password=123456
4,数据库未启动或无权访问
5,项目未引入对应的驱动jar包mysql-connector-java-5.1.8.jar
6,mysql root没有远程访问的权限,需要增加权限,增加权限的步骤如下:
进入mysql数据库:
grant all privileges on *.* to 'donald'@'%' identified by '123456';
flush privileges;
如果上面没有解决,看看c3p0.properties属性配置是不是有错
属性后面不要有空格
相关推荐
**P6Spy SQL监控工具详解** ...总结来说,P6Spy是一个强大的SQL监控工具,它能够帮助我们更好地理解数据库性能、优化SQL语句以及保障数据安全。正确配置和使用P6Spy,可以显著提升Java应用程序的数据库管理效率。
P6Spy是一个开源的JDBC代理库,它允许我们监控并记录应用通过JDBC执行的所有数据库操作,包括那些由Hibernate生成的SQL语句。它不仅可以提供完整的SQL语句,还能够提供执行时间、性能指标等详细信息,这对于优化...
P6spy是一个JDBC Driver的包装工具,p6spy通过对JDBC Driver的封装以达到对SQL语句的监听和分析,以达到各种目的。 p6spy的安装步骤: 1. 下载p6spy的安装包 2. 把p6spy的jar包放到Classpath中,如果是WEB App...
P6Spy通过拦截并记录SQL语句,为开发者提供了一种无侵入式的监控解决方案。它的工作原理是在JDBC驱动层插入一个代理,所有数据库访问请求都会经过这个代理,因此可以捕获到所有的SQL操作。P6Spy的配置相对简单,只...
P6Spy是一个广泛使用的开源框架,它允许开发者无侵入地监控和记录应用程序中的所有SQL语句。这个项目的目标是借鉴P6Spy的部分源码,创建一个自定义的SQL执行监控器,以满足特定的需求或提供更定制化的功能。 P6Spy...
然而,为了优化数据库性能、排查问题,我们往往需要监控和分析应用程序执行的SQL语句。这就引入了两个强大的工具——P6Spy和SqlProfiler,它们专门用于打印和分析JDBC执行的真实SQL。 P6Spy是一个开源的Java库,...
本文将详细探讨如何使用P6Spy来打印iBatis(现为MyBatis)执行的SQL语句,以便进行性能分析和调试。 首先,我们需要了解P6Spy的工作原理。P6Spy通过替换JDBC驱动,将自己插入到应用程序和数据库之间,监听所有的SQL...
P6spy和SqlProfiler则是两个用于数据库性能监控和分析的工具。这篇内容将详细解释如何将这三者集成,以提升对数据库操作的监控效率。 【P6spy】 P6spy是一个开源的数据库监控工具,它能够拦截并记录应用程序与...
2. **p6spy**:p6spy是一个代理库,它可以拦截并记录数据库连接的所有SQL语句,包括执行时间、错误信息等。它通过替换JDBC驱动来实现这一功能,因此无需修改应用程序代码。p6spy的配置通常包括设置`spy.properties`...
WebLogic Server 11g是一...通过以上配置,WebLogic Server 11g将能够使用P6Spy和SQL Profiler进行数据库性能监控,为系统的优化提供数据支持。记得定期检查和分析日志,持续优化数据库性能,以保持系统高效稳定运行。
`p6spy`是一个非常实用的开源工具,它能够帮助我们监控和记录应用通过JDBC执行的所有SQL语句。这篇博客“使用p6spy完整显示hibernate的SQL语句”可能详细解释了如何配置和使用p6spy来跟踪Hibernate生成并执行的SQL。...
《P6Spy与SQLProfiler:全面监控SQL性能的利器》 在数据库管理中,了解SQL语句的执行情况是至关重要的。为了优化数据库性能,我们需要深入理解SQL查询的行为,包括执行时间、资源消耗等。这正是P6Spy和SQLProfiler...
通过 P6Spy 我们可以对 SQL 语句进行拦截,相当于一个 SQL 语句的记录器,这样我们可以用它来作相关的分析,比如性能分析。P6Spy 用 Log4J 来记录 JDBC 调用的日记信息。 自从 2003 年 11 月 30 日 P6Spy 版本 1.3 ...
P6Spy通过拦截和记录SQL语句,为开发者提供了详细的日志信息,包括执行时间、连接信息等,有助于识别慢查询和优化数据库性能。配置P6Spy主要涉及修改数据库驱动类名,设置配置文件路径以及在应用中引入P6Spy的JAR...
1. **SQL日志记录**:P6Spy 可以捕获并记录应用程序执行的所有SQL语句,包括参数和执行时间,这对于调试和性能分析非常有用。 2. **格式化输出**:P6Spy 提供了自定义的日志格式,可以按照开发者的需求定制输出信息...
p6spy 是一个开源的 Java 框架,它的主要功能是在不修改代码的情况下,监控和记录 Java 应用程序中执行的所有 SQL 语句。这个工具对于开发者来说非常有用,因为它可以帮助定位性能瓶颈,特别是在使用 ORM(对象关系...
p6spy dataSource 配置 监听真实sql语句
- **开发测试**:在开发阶段,P6Spy可以作为SQL日志工具,帮助开发者验证SQL语句的正确性和效率。 8. **与其他监控工具对比** 相比其他数据库监控工具,如Log4j的JDBC Appender,P6Spy的优势在于无需修改应用程序...
【p6spy精简版-跟踪SQL工具】是一款专为数据库操作监控设计的工具,它通过对JDBC驱动的拦截,实现对SQL语句的透明跟踪。这个精简版旨在简化p6spy的原生配置和使用流程,让更多非开发人员也能便捷地利用此工具来监控...
1. 性能监控:通过分析 P6Spy 的日志,可以找出执行慢的 SQL,进而优化数据库查询。 2. 问题排查:当遇到数据库相关的问题时,查看 P6Spy 的日志可以帮助定位问题所在,因为它们提供了完整的 SQL 语句及其执行上下文...