使用Mybatis添加用户时报:Setting autocommit to false on JDBC Connection

2019-01-24 15:18:13,391 0      [           main] DEBUG ache.ibatis.logging.LogFactory  - Logging initialized using 'class org.apache.ibatis.logging.log4j.Log4jImpl' adapter.
2019-01-24 15:18:13,632 241    [           main] DEBUG source.pooled.PooledDataSource  - PooledDataSource forcefully closed/removed all connections.
2019-01-24 15:18:13,636 245    [           main] DEBUG source.pooled.PooledDataSource  - PooledDataSource forcefully closed/removed all connections.
2019-01-24 15:18:13,637 246    [           main] DEBUG source.pooled.PooledDataSource  - PooledDataSource forcefully closed/removed all connections.
2019-01-24 15:18:13,637 246    [           main] DEBUG source.pooled.PooledDataSource  - PooledDataSource forcefully closed/removed all connections.
2019-01-24 15:18:13,842 451    [           main] DEBUG ansaction.jdbc.JdbcTransaction  - Opening JDBC Connection
2019-01-24 15:18:14,216 825    [           main] DEBUG source.pooled.PooledDataSource  - Created connection 242355057.
2019-01-24 15:18:14,216 825    [           main] DEBUG ansaction.jdbc.JdbcTransaction  - Setting autocommit to false on JDBC Connection [com.mysql.jdbc.JDBC4Connection@e720b71]
2019-01-24 15:18:14,219 828    [           main] DEBUG om.company.dao.UserDao.addUser  - ==>  Preparing: insert into user (username,birthday,sex,address) value (?,?,?,?) ; 
2019-01-24 15:18:14,269 878    [           main] DEBUG om.company.dao.UserDao.addUser  - ==> Parameters: 老王(String), 2019-01-24 15:18:13.825(Timestamp), 女(String), 隔壁(String)
2019-01-24 15:18:14,269 878    [           main] DEBUG om.company.dao.UserDao.addUser  - <==    Updates: 1
2019-01-24 15:18:14,276 885    [           main] DEBUG .dao.UserDao.addUser!selectKey  - ==>  Preparing: select last_insert_id(); 
2019-01-24 15:18:14,276 885    [           main] DEBUG .dao.UserDao.addUser!selectKey  - ==> Parameters: 
2019-01-24 15:18:14,301 910    [           main] DEBUG .dao.UserDao.addUser!selectKey  - <==      Total: 1

使用Mybatis添加用户时,显示添加成功,但数据库中没有添加的数据。

Sqlsession默认把自动事务提交给关闭了,开启了手动事务提交,只有把事务提交,数据才能提交到数据库。

你可能感兴趣的:(使用Mybatis添加用户时报:Setting autocommit to false on JDBC Connection)