下載地址:https://repo1.maven.org/maven2/p6spy/p6spy/3.0.0/p6spy-3.0.0.zip;sql
一、在工程中lib加入p6spy.jar文件,同時加入p6spy.properties文件到工程相應位置,修改其driverlist爲項目JDBC驅動,例如:driverlist=oracle.jdbc.driver.OracleDriveroracle
若是想在控制檯打印sql語句 取消註釋appender=com.p6spy.engine.spy.appender.StdoutLoggerapp
若是想將sql輸出到日誌就要把appender註釋掉,而且能夠修改輸出日誌文件位置,例如:logfile = c:/spy.logmaven
二、修改原工程DataSourceURL,例如原來的jdbc:oracle:thin:@localhost:1521:orcl,修改爲jdbc:p6spy:oracle:thin:@localhost:1521:orcl,驅動修改爲om.p6spy.engine.spy.P6SpyDriver.net
兩步搞定,之後就能夠輕鬆調試SQL。調試