MyBatis Introduction
MyBatis is an excellent persistence layer framework that supports common SQL queries, stored procedures, and advanced mappings. MyBatis eliminates the manual setting of almost all JDBC code and parameters and the retrieval encapsulation of the result set. MyBatis can use simple XML or annotations for configuration and raw mappings, mapping interfaces and Java Pojo (Plain old Java Objects, normal Java objects) to records in the database.
Below look at the MyBatis console print SQL statement
1. First move the Ibatis log4j run level to debug to print out the SQL statements Ibatis run on the console
2. Add the following statement
# # #显示SQL语句部分
log4j.logger.com.ibatis=debug
log4j.logger.com.ibatis.common.jdbc.simpledatasource=debug
Log4j.logger.com.ibatis.common.jdbc.scriptrunner=debug
Log4j.logger.com.ibatis.sqlmap.engine.impl.sqlmapclientdelegate=debug
log4j.logger.java.sql.connection= DEBUG
log4j.logger.java.sql.statement=debug
log4j.logger.java.sql.preparedstatement=debug
Below look at the MyBatis and Ibatis console print SQL statements
#将ibatis log4j Run level to debug can print out Ibatis run SQL statement log4j.rootlogger=debug,stdout in the console. LogFile ### output log information to the console ### Log4j.appender.stdout=org.apache.log4j.consoleappender #log4j. appender.stdout.target=
System.err log4j.appender.stdout.layout=org.apache.log4j.simplelayout ### Output log information to file: Jbit.log ###
Log4j.appender.logfile=org.apache.log4j.fileappender Log4j.appender.logfile.file=d:/test.log Log4j.appender.logfile.layout=org.apache.log4j.patternlayout log4j.appender.logfile.layout.conversionpattern=%d
{yyyy-mm-dd HH:mm:ss}%F%p%m%n # # #显示SQL语句部分 Log4j.logger.com.ibatis=debug Log4j.logger.com.ibatis.common.jdbc.simpledatasource=debug log4j.logger.com.ibatis.common.jdbc.scriptrunner= DEBUG Log4j.logger.com.ibatis.sqlmap.engine.impl.sqlmapclientdelegate=debug log4j.logger.java.sql.connection= DEBUG log4j.logger.java.sql.statement=debug log4j.logger.java.sql.preparedstatement=debug
The above is a small set to introduce the MyBatis console print SQL statement Implementation code, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!