Hibernate 응용 프로그램에서 P6SPY를 사용하여 JDBC 문을 데이터베이스에 인터셉트합니다.

StackOverflow https://stackoverflow.com/questions/5044804

  •  15-11-2019
  •  | 
  •  

문제

Hibernate 콘솔 응용 프로그램을 개발 하고이 기사 http://www.mkyong.com/hibernate/how-to-display-hibernate-sql-parameter-values-solution/ 실제 값이 무엇인지 확인하기 위해 p6spy를 설정합니다. Hibernate에 의해 생성 된 SQL의 "(?)"의 "(?)".

응용 프로그램이 시작되는 동안 P6SPY로 출력하는 정보 / 디버그 메시지를 볼 수 있으므로 설정이 잘 작동해야합니다. 그러나 그 후에 P6SPS는 JDBC 문을 가로 챌 수없는 것으로 보입니다. Hibernate (예 : Hibernate: insert into Module (projectName, moduleName, projectId) values (?, ?, ?))에 의해 생성 된 로그에서 JDBC 문이 이미 데이터베이스로 전송되는지 확인할 수 있습니다.

다음은 내 설정입니다 :

hibernate.cfg.xml

  • 는 이미 p6spy를 사용하도록 지정되었습니다 드라이버 : <property name="hibernate.connection.driver_class">com.p6spy.engine.spy.P6SpyDriver</property>
  • 는 이미 켜져 있습니다 hibernate.show_sql 속성 : <property name="hibernate.show_sql">true</property>

    spy.properties

    • 가 이미 내 실제를 사용하도록 변경되었습니다 데이터베이스 JDBC 드라이버, 필터 세트로 설정 false, includeCategories 이미 있습니다 명시 적으로 아무 것도 로그로 설정합니다.
      module.log=com.p6spy.engine.logging.P6LogFactory
      realdriver=oracle.jdbc.driver.OracleDriver
      filter=false
      dateformat=yyyy.MM.dd HH:mm:ss
      excludecategories=
      includecategories=error, info, batch, debug,statement,commit,rollback,result
      appender=com.p6spy.engine.logging.appender.StdoutLogger
      
      .

      어떤 중요한 설정을 그리워합니까 ??

도움이 되었습니까?

해결책 3

Finally , I give up P6Spy as it is the old library which the latest version is back to 2003. I resort to use another similar free open source called log4jdbc to intercept the JDBC statements , see this for more info if you are interested.

다른 팁

I've never used P6Spy, but you can get the bind variables to output to your log. Try putting this in your log4j.properties or xml file.

log4j.category.org.hibernate.type=DEBUG, CONSOLE

The usual cause for this type of problem is that the JDBC driver is loaded before the P6SpyDriver. You can get around this problem by setting deregisterdrivers=true in spy.properties.

BTW - This issue was fixed in 2.0-alpha-1.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top