開拓自己

          NeverDrop

            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
            0 隨筆 :: 14 文章 :: 0 評論 :: 0 Trackbacks
          conn.setAutoCommit(false);不讓數據自動提交
          stmt=conn.createStatement();
          stmt.addBatch("語句1");
          stmt.addBatch("語句2");
          stmt.executeBatch();//批處理
          conn.commit();//提交事務
          cinn.setAutoCommit(true););//當conn回到初狀態!能自動提交!


          在這里面捕捉異常
          catch(SQLException e)
          {
          e.printStackTrace();
          try{
          if(conn!=null)
          {
          conn.rollback();//回滾
          conn.setAutoCommit(true);//當conn回到初狀態!能自動提交!
          }
          catch(SQLException el)
          {
          el.printStackTrace();
          }
          }
          }
          posted on 2007-01-02 18:29 誠夏徠 閱讀(170) 評論(0)  編輯  收藏 所屬分類: j2ee
          主站蜘蛛池模板: 昌江| 循化| 潼南县| 称多县| 大余县| 博客| 霍山县| 哈尔滨市| 菏泽市| 温泉县| 乐东| 广河县| 沅江市| 金华市| 大石桥市| 来安县| 额敏县| 宣恩县| 赣州市| 福海县| 雅安市| 马鞍山市| 财经| 虞城县| 拜城县| 通山县| 商洛市| 安乡县| 乌什县| 绍兴市| 鄢陵县| 安顺市| 大厂| 铜山县| 高密市| 平邑县| 阳东县| 会同县| 米林县| 荣昌县| 青川县|