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 閱讀(769) 評論(0)  編輯  收藏


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


          網站導航:
           

          公告

          希望有一天

          我能用鼠標雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導航

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

          統計

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網絡

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 响水县| 崇阳县| 连平县| 理塘县| 保德县| 黄大仙区| 潮安县| 扶绥县| 香格里拉县| 延川县| 天水市| 阿勒泰市| 逊克县| 泰来县| 嘉荫县| 买车| 新河县| 湘西| 名山县| 锡林浩特市| 原平市| 贵州省| 连云港市| 东乡族自治县| 成都市| 盖州市| 平湖市| 绩溪县| 临沧市| 巩留县| 横峰县| 屏山县| 麻栗坡县| 巴中市| 内江市| 桂阳县| 洪雅县| 上犹县| 日照市| 涡阳县| 双辽市|