【MyBatis笔记】MyBatis 配置SQL打印

MyBatis 配置SQL打印

在 SqlMappingConfig.xml 中配置以下代码:

<!--配置sql打印-->
<settings>
    <setting name="logImpl" value="STDOUT_LOGGING"/>
</settings>

运行效果:会显示 SQL 语句,查询结果,总共几条数据,最后把数据封装成对象。

Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
PooledDataSource forcefully closed/removed all connections.
PooledDataSource forcefully closed/removed all connections.
PooledDataSource forcefully closed/removed all connections.
PooledDataSource forcefully closed/removed all connections.
Opening JDBC Connection
Created connection 19717364.
Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@12cdcf4]
==>  Preparing: SELECT * FROM `customer` WHERE cust_id = ? 
==> Parameters: 1(Integer)
<==    Columns: cust_id, cust_name, cust_profession, cust_phone, email
<==        Row: 1, 鲁班, 射手, 13499887733, 12341241@qq.com
<==      Total: 1
Customer{cust_id=1, cust_name='鲁班', cust_profession='射手', cust_phone='13499887733', email='12341241@qq.com'}
Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@12cdcf4]
Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@12cdcf4]
Returned connection 19717364 to pool.
上一篇:Mysql 修改最大链接数


下一篇:LeetCode 1135. Connecting Cities With Minimum Cost