java - Can't achieve working with p6Spy -


i've tried 2 methods adding p6spy feature spring used project.

route i,

http://templth.blogspot.com.tr/2004/11/integrate-p6spy-with-spring.html changed driver com.p6spy.engine.spy.p6spydriver , added realdriver realdriver=com.ibm.db2.jcc.db2driver spy.properties file.

but somehow realdriver being registered before p6spy driver com.ibm.db2.jcc.db2driver real driver in spy.properties, has been loaded before p6spy. p6spy not wrap these connections.either prevent driver loading, or try setting 'deregisterdrivers' true in spy.properties

using :p6spy: prefix doesn't work me. says can't establish connection url.

so,i chose setting deregisterdrivers=true in property file. time sql in log file can't execute sqls. i'm able execute sql in sql editor. seemed real connection went , dummy 1 came.

route ii, use spring. i've tried method. giving datasource explicitly p6spy. time spring complained of multiple java.sql.datasource instance. both com.firm.basicdatafill , com.p6spy.engine.spy.p6datasource implements datasource. spring can't obtain singleton.

http://templth.blogspot.com.tr/2004/11/integrate-p6spy-with-spring.html

<bean id="datasource" lazy-init="true"     class="com.firm.basicdatafill">     <property name="driverclassname" value="${database.connection.driver_class}" />     <property name="username" value="${database.connection.username}" />     <property name="password" value="${database.connection.password}" />     <property name="url" value="${database.connection.url}" />        ...     <property name="accesstounderlyingconnectionallowed" value="true" />                                 </bean>  <!-- bean id="mydatasource" class="com.p6spy.engine.spy.p6datasource">     <constructor-arg>         <ref local="datasource"/>     </constructor-arg> </bean--> 

finally, discovered p6spy v1.3 , 2.4.1 settings vary. have suggestion spring based application.

i recommend starting latest version of p6spy 2.x. should replace spy.properties file default version 2.x documented here. depending on application server, might need set 'realdriver' setting in spy.properties include 'com.ibm.db2.jcc.db2driver'. however, needed when using application server prevents automatic registration of jdbc drivers.

to use p6spy spring, easiest method wrap current data source bean p6spydatasource discussed here. example in answer shows jndi data source being wrapped can used wrap data source. note: if wrapping data source p6spydatasource, not need modify jdbc url.

if continue have problems, please add bit more information question. following information helpful in troubleshooting:

  1. the version of p6spy being used
  2. the contents of spy.properties
  3. the definition of datasource (including app server config if using jndi)
  4. the type of app server , version being used
  5. stacktrace containing whatever error might have received.

Comments