gnl

          java 學習
          隨筆 - 17, 文章 - 0, 評論 - 2, 引用 - 0
          數據加載中……

          mybatis 學習記錄

          在mybatis 中無法插入記錄

          顯示信息如下:

          SLF4J: This version of SLF4J requires log4j version 1.2.12 or later. See also http://www.slf4j.org/codes.html#log4j_version
          0    DEBUG [main]  org.apache.ibatis.logging.LogFactory     - Logging initialized using 'class org.apache.ibatis.logging.slf4j.Slf4jImpl' adapter.
          31   DEBUG [main] org.apache.ibatis.datasource.pooled.PooledDataSource     - PooledDataSource forcefully closed/removed all connections.
          31   DEBUG [main] org.apache.ibatis.datasource.pooled.PooledDataSource     - PooledDataSource forcefully closed/removed all connections.
          31   DEBUG [main] org.apache.ibatis.datasource.pooled.PooledDataSource     - PooledDataSource forcefully closed/removed all connections.
          31   DEBUG [main] org.apache.ibatis.datasource.pooled.PooledDataSource     - PooledDataSource forcefully closed/removed all connections.
          140  DEBUG [main] org.apache.ibatis.transaction.jdbc.JdbcTransaction     - Opening JDBC Connection
          483  DEBUG [main] org.apache.ibatis.datasource.pooled.PooledDataSource     - Created connection 6259058.
          483  DEBUG [main] com.te.mybatis.persitence.ifance.PersonDao.insertperson     - ooo Using Connection [com.mysql.jdbc.JDBC4Connection@5f8172]
          483  DEBUG [main] com.te.mybatis.persitence.ifance.PersonDao.insertperson     - ==>  Preparing: insert into person(username) values('tomcat23')
          530  DEBUG [main] com.te.mybatis.persitence.ifance.PersonDao.insertperson     - ==> Parameters:
          530  DEBUG [main] org.apache.ibatis.transaction.jdbc.JdbcTransaction     - Rolling back JDBC Connection [com.mysql.jdbc.JDBC4Connection@5f8172]
          561  DEBUG [main] org.apache.ibatis.transaction.jdbc.JdbcTransaction     - Resetting autocommit to true on JDBC Connection [com.mysql.jdbc.JDBC4Connection@5f8172]
          561  DEBUG [main] org.apache.ibatis.transaction.jdbc.JdbcTransaction     - Closing JDBC Connection [com.mysql.jdbc.JDBC4Connection@5f8172]
          561  DEBUG [main] org.apache.ibatis.datasource.pooled.PooledDataSource     - Returned connection 6259058 to pool.

          運行插入語句始終不能成功,但是一直沒有注意這個語句
          530  DEBUG [main] org.apache.ibatis.transaction.jdbc.JdbcTransaction     - Rolling back JDBC Connection [com.mysql.jdbc.JDBC4Connection@5f8172]
          想一想在insert里面也沒有用到事務啊,不知道是什么原因?

          在執行語句出添加事務提交 就可以插入成功 ,

                  SqlSession sqlsesstion = sc.openSession();

                  sqlsesstion.insert("insertperson", person);
                  sqlsesstion.commit();  //還不知道是什么原因要提交事務才可以插入數據成功,但是每一次似乎都對數據庫產生了影響
                  sqlsesstion.close();



          有一點亂 !!!





          posted on 2013-07-04 12:10 一江 閱讀(3106) 評論(1)  編輯  收藏 所屬分類: ibatis學習

          評論

          # re: mybatis 學習記錄  回復  更多評論   

          創造極致獵頭服務 www.51znt.com
          2014-09-11 09:35 | 智囊團
          主站蜘蛛池模板: 阿城市| 遂昌县| 五华县| 石嘴山市| 延川县| 台东市| 庆云县| 大同市| 缙云县| 婺源县| 宾阳县| 会理县| 留坝县| 青神县| 泾川县| 苗栗县| 且末县| 子洲县| 孝感市| 新乡市| 济宁市| 晋中市| 兴海县| 凤庆县| 明光市| 家居| 商河县| 苗栗县| 资源县| 绥中县| 西安市| 万载县| 清涧县| 手游| 雷州市| 达尔| 南投市| 栾城县| 阜平县| 西丰县| 富阳市|