Loading...

          java .net

          Oracle insert大字符串方法


          Oracle insert大字符串方法
          try {
                      conn = getConnection();
                      pstmt = conn
                              .prepareStatement("Insert into offidutychk(decno,offino,checkdate,checkcontent) "+
                                                  "Values(seq_decno.nextval, ?,?,?)");
                      pstmt.setString(1, hezhi.getOffino());
                      pstmt.setDate(2, hezhi.getCheckDate());
                      pstmt.setCharacterStream(3,
                              new InputStreamReader(new ByteArrayInputStream(hezhi.getCheckContent().getBytes())), hezhi.getCheckContent().length());
                      //pstmt.setString(3, hezhi.getCheckContent());
                     
          //            判斷插入操作是否成功
                      if (pstmt.executeUpdate() == 1)
                          succ = true;
                      else
                          succ = false;
                  } catch (Exception e) {
                      succ = false;
                      e.printStackTrace();
                  } finally {
                      try {
                          pstmt.close();
                      } catch (Exception e) {
                          e.printStackTrace();
                          // TODO: handle exception
                      }
                     
                      closeConnection(conn);
                  }







          Oracle update大字符串方法
                  Connection conn = null;
                  PreparedStatement pstmt = null;
                  int length=hezhi.getCheckContent().length();
                  String s1="";
                  String s2="";
                  if(length>1000){
                      s1=hezhi.getCheckContent().substring(0,1000);
                      s2=hezhi.getCheckContent().substring(1000,length);
                  }else{
                      s1=hezhi.getCheckContent();
                     
                  }
          try {
                      conn = getConnection();
                      pstmt = conn
                              .prepareStatement("update offidutychk set checkdate=?,checkcontent=?||? "+
                                                  "where decno=?");
                     
                      pstmt.setDate(1, hezhi.getCheckDate());
                     
          //            pstmt.setCharacterStream(2,
          //                    new InputStreamReader(new ByteArrayInputStream(hezhi.getCheckContent().getBytes())), hezhi.getCheckContent().length());
          //            //pstmt.setString(2, hezhi.getCheckContent());
                      pstmt.setString(2, s1);
                      pstmt.setString(3, s2);
                      pstmt.setInt(4, hezhi.getDecno());
                     
          //            判斷更新操作是否成功
                      if (pstmt.executeUpdate() == 1)
                          succ = true;
                      else
                          succ = false;
                  } catch (Exception e) {
                      succ = false;
                      e.printStackTrace();
                  } finally {
                      try {
                          pstmt.close();
                      } catch (Exception e) {
                          e.printStackTrace();
                      }
                     
                      closeConnection(conn);
                  }

          posted on 2008-08-26 22:06 閱讀(770) 評論(0)  編輯  收藏


          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

          <2008年8月>
          272829303112
          3456789
          10111213141516
          17181920212223
          24252627282930
          31123456

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 阳江市| 巴青县| 察哈| 耒阳市| 彭泽县| 六安市| 大姚县| 尚志市| 万山特区| 屏南县| 乐至县| 班玛县| 特克斯县| 体育| 柳林县| 井陉县| 鹿泉市| 育儿| 筠连县| 开江县| 夏津县| 屏南县| 微博| 永仁县| 福安市| 边坝县| 中方县| 明星| 茂名市| 万全县| 鄂州市| 密云县| 嘉祥县| 柯坪县| 武陟县| 南岸区| 略阳县| 宣武区| 忻州市| 通榆县| 凤城市|