Spring+Hibernate集成p6spy和sqlprofiler

1、下载p6spysqlprofiler

2、拷贝p6spy.jar和sqlprofiler.jar到WEB-INF/lib下

3、拷贝spy.properies到WEB-INF/classes下

4、编辑spy.properies中JDBC驱动为实际的JDBC驱动

5、注意先启动java -jar sqlprofiler.jar,然后启动web服务器

p6spy与spring集成,用com.p6spy.engine.spy.P6DataSource包装spring的datasouce,如下:

<bean id="dataSourceTarget"
        class="org.apache.commons.dbcp.BasicDataSource">
        <property name="driverClassName">
            <value>oracle.jdbc.OracleDriver</value>
        </property>
        <property name="url">
            <value>jdbc:oracle:thin:@10.211.2.27:1521:mm</value>
        </property>
        <property name="username">
            <value>mm</value>
        </property>
        <property name="password">
            <value>mm</value>
        </property>
        <property name="defaultAutoCommit">
            <value>false</value>
        </property>
        <property name="maxActive">
            <value>5</value>
        </property>
    </bean>
    <bean id="dataSource" class="com.p6spy.engine.spy.P6DataSource"
        destroy-method="close">
        <constructor-arg>
            <ref local="dataSourceTarget" />
        </constructor-arg>
    </bean>

你可能感兴趣的:(spring,oracle,Hibernate,bean,jdbc)