我有一个程序,它使用准备好的语句更新数据库中的表,并且我正在尝试查看所有已实现的SQL语句的输出。
我的研究表明,P6Spy看起来很棒,我下载了它,在我的库中添加了P6Spy.jar作为依赖项,修改到spy.properties文件以连接到使用oracle驱动程序作为realdriver,将spy.properties添加到我的类路径中,并在代码中将驱动程序更改为"com.p6spy.engine.spy.P6SpyDriver“。
它全部工作,spy.log文件是生成的,但它不包含SQL语句。相反,spy.log文件中的输出是:
1374244954573|-1||debug||com.p6spy.engine.common.P6SpyOptions reloading properties
1374244954578|-1||info||Using properties file: C:\Users\gboss\logging\spy.properties
1374244954579|-1||info||No value in environment for: getStackTrace, using: false
1374244954579|-1||info||No value in environment for: getDeregisterDrivers, using: false
1374244954579|-1||info||No value in environment for: getUsePrefix, using: false
1374244954579|-1||info||No value in environment for: getExecutionThreshold, using: 0
1374244954579|-1||info||No value in environment for: getAutoflush, using: true
1374244954579|-1||info||No value in environment for: getExclude, using:
1374244954579|-1||info||No value in environment for: getExcludecategories, using: info,debug,result,batch
1374244954579|-1||info||No value in environment for: getFilter, using: true
1374244954579|-1||info||No value in environment for: getInclude, using:
1374244954579|-1||info||No value in environment for: getIncludecategories, using:
1374244954579|-1||info||No value in environment for: getLogfile, using: c:/spy.log
1374244954579|-1||info||No value in environment for: getAppender, using: com.p6spy.engine.logging.appender.FileLogger
1374244954579|-1||info||No value in environment for: getRealdriver, using: oracle.jdbc.driver.OracleDriver
1374244954579|-1||info||No value in environment for: getRealdriver2, using:
1374244954580|-1||info||No value in environment for: getRealdriver3, using:
1374244954580|-1||info||No value in environment for: getAppend, using: true
1374244954580|-1||info||No value in environment for: getSpydriver, using: com.p6spy.engine.spy.P6SpyDriver
1374244954580|-1||info||No value in environment for: getDateformat, using:
1374244954580|-1||info||No value in environment for: getDateformatter, using: null
1374244954580|-1||info||No value in environment for: getStringmatcher, using: com.p6spy.engine.common.SubstringMatcher
1374244954580|-1||info||No value in environment for: getStringMatcherEngine, using: com.p6spy.engine.common.SubstringMatcher@13aaa14a
1374244954580|-1||info||No value in environment for: getStackTraceClass, using:
1374244954580|-1||info||No value in environment for: getSQLExpression, using: null
1374244954580|-1||info||No value in environment for: getReloadProperties, using: false
1374244954580|-1||info||No value in environment for: getReloadPropertiesInterval, using: 60
1374244954580|-1||info||No value in environment for: getJNDIContextFactory, using: null
1374244954580|-1||info||No value in environment for: getJNDIContextProviderURL, using: null
1374244954580|-1||info||No value in environment for: getJNDIContextCustom, using: null
1374244954580|-1||info||No value in environment for: getRealDataSource, using: null
1374244954580|-1||info||No value in environment for: getRealDataSourceClass, using: null
1374244954580|-1||info||No value in environment for: getRealDataSourceProperties, using: null有谁有使用P6Spy的经验并且知道问题所在吗?我读到spy.log应该在做完我做的所有事情并运行程序之后生成sql语句,所以我在这里很困惑
编辑 --顺便说一句,数据库已经更新了,所以SQL语句确实遍历并更新了数据库。
发布于 2014-01-31 18:21:20
这通常是由于注册了真正的JDBC驱动程序后在P6SpyDriver中注册的DriverManager造成的。JDBC1.3不要求您更改JDBC。当应用程序代码(或app服务器)试图从DriverManager获得合适的驱动程序时,它会在注册的驱动程序中循环以找到第一个处理URL的驱动程序。如果P6SpyDriver没有在真正的驱动程序之前注册,那么它就不会被使用。
有两种方法可以解决这个问题:
这将导致P6Spy注销真正的驱动程序,然后重新注册它。这将导致DriverManager使用P6SpyDriver。但是,使用6+,您必须确保为实际驱动程序列出的驱动程序类与将自动注册的驱动程序类匹配。您可以从META/services/java.sql.Driver获得这个类名。如果JAR文件中不存在JDBC驱动程序的文件,那么它不支持自动注册。
这将确保无论加载驱动程序的顺序如何,都将使用P6SpyDriver。这实际上是最可靠的方法..。
请参阅http://p6spy.github.io/p6spy/1.3/configandusage.html,以获得1.3版的各种配置选项。
https://stackoverflow.com/questions/17749152
复制相似问题