您可以使用Mybatis記錄SQL語句。
它產生SQL語句準備登錄象下面這樣:
Preparing: SELECT USER_ID AS userId, PASSWORD AS password, USER_NAME AS userName FROM USER_MST WHERE USER_NAME = ? AND PASSWORD = ? AND DELETE_FLAG = 0
Parameters: test_uname(String), test_pass(String)
Here是MyBatis的日誌文件。
以下是mybatis的示例日誌配置。
<?xml version="1.0" encoding="UTF-8"?>
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="false">
<appender name="APPLICATION" class="org.apache.log4j.DailyRollingFileAppender">
<param name="file" value="C:/log/mybatis.log" />
<param name="MaxBackupIndex" value="10" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MM-dd HH:mm:ss,SSS} |%5p| [%c] | %m%n" />
</layout>
</appender>
<logger name="YourMapperXML" additivity="false">
<level value="DEBUG" />
<appender-ref ref="APPLICATION" />
</logger>
</log4j:configuration>
看看這有助於http://stackoverflow.com/questions/13195144/can-i-use-mybatis-to-generate-dynamic-sql-without-executing-it/ – Bogdan