SQL日志Java開源類庫,P6SPY 2.0 發布
P6Spy是一個可以用來在Java應用程序中攔截和修改數據庫SQL操作語句的開源框架。 通過P6Spy我們可以對SQL語句進行攔截,相當于一個SQL語句的日志工具,可以用它來作相關的分析,比如性能分析。
P6SPY提供了如下幾個功能:
記錄SQL語句的執行時間戳。
記錄SQL語句類型
記錄SQL填入參數的和沒有填入參數的SQL語句
根據配置的時間控制SQL語句的執行時間,對超出時間的SQL語句輸出到日志文件中。
下載地址:https://github.com/p6spy/p6spy/wiki/Download
詳細改進內容包括:
-
project hosting was moved from sourceforge to github,
-
major part of the legacy code was refactored,
-
Java 6/7 JDBC API support introduced,
-
proxying via modified
JDBC
URL
s only was implemented,
So for for MySQL original url would be:jdbc:mysql://<hostname>:<port>/<database>
the one proxied via p6spy would one:
jdbc:p6spy:mysql://<hostname>:<port>/<database>
without a need for any further configuration,
-
XA Datasource support has been introduced,
-
configuration via:
-
system/environment properties and
-
JMX properties
-
as an alternative to file configuration only
-
or even zero config use case supported,
-
slf4j support (more flexible as previously used log4j),
-
junit tests were migrated to junit 4 (well most of the old ones were failing anyway),
-
Continuous integration using Travis was setup providing testing on popular:
-
DB systems (namely: Oracle, DB2, PostgreSQL, MySQL, H2, HSQLDB, SQLite, Firebird, and Derby), see build status on: travis-ci as well as
-
application servers (namely: Wildfly 8, JBoss 4.2, 5.1, 6.1, 7.1, Glassfish 3.1, 4.0, Jetty 7.6, 8.1, 9.1, Tomcat 6, 7, 8, Resin 4, Jonas 5.3 and Geronimo 2.1, 2.2), see build status on: travis-ci.