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 | 智囊團
          主站蜘蛛池模板: 阜南县| 新野县| 来安县| 信宜市| 镇远县| 寿宁县| 井研县| 高要市| 南川市| 贡觉县| 文安县| 逊克县| 东莞市| 涪陵区| 宁河县| 正定县| 噶尔县| 新丰县| 岳阳县| 桐乡市| 阜宁县| 鄂温| 大英县| 峡江县| 哈尔滨市| 收藏| 富源县| 朔州市| 阿克陶县| 清涧县| 长乐市| 合水县| 福建省| 恩平市| 镇康县| 家居| 华安县| 璧山县| 河池市| 偃师市| 高台县|