使用Hibernate提供的内置属性<property name="show_sql">true</property>只能输出带占位符的sql语句,这样不利于程序调试。
如果我们需要完整的sql语句,那该怎么办呢?别担心,p6spy帮助你。
1、将p6spy.jar放入lib目录内。
2、根据你的项目情况适当修改spy.properties属性文件,并将其放入项目路径下,即src目录下,以下是spy.properties属性文件的详细信息:
#################################################################
# MODULES #
# #
# Modules provide the P6Spy functionality. If a module, such #
# as module_log is commented out, that functionality will not #
# be available. If it is not commented out (if it is active), #
# the functionality will be active. #
# #
# Values set in Modules cannot be reloaded using the #
# reloadproperties variable. Once they are loaded, they remain #
# in memory until the application is restarted. #
# #
#################################################################
module.log=com.p6spy.engine.logging.P6LogFactory
#module.outage=com.p6spy.engine.outage.P6OutageFactory
#################################################################
# REALDRIVER(s) #
# #
# In your application server configuration file you replace the #
# "real driver" name with com.p6spy.engine.P6SpyDriver. This is #
# where you put the name of your real driver P6Spy can find and #
# register your real driver to do the database work. #
# #
# If your application uses several drivers specify them in #
# realdriver2, realdriver3. See the documentation for more #
# details. #
# #
# Values set in REALDRIVER(s) cannot be reloaded using the #
# reloadproperties variable. Once they are loaded, they remain #
# in memory until the application is restarted. #
# #
#################################################################
# the hsqldb open source driver
#realdriver=org.hsqldb.jdbcDriver
# oracle driver
#realdriver=oracle.jdbc.driver.OracleDriver
# mysql Connector/J driver
realdriver=com.mysql.jdbc.Driver
# informix driver
# realdriver=com.inform