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) 評(píng)論(0)  編輯  收藏


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          公告

          希望有一天

          我能用鼠標(biāo)雙擊我的錢包

          然后選中一張100元

          按住“ctrl+c”

          接著不停的“ctrl+v”

          嘻嘻~~~笑醒~~~



          導(dǎo)航

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

          統(tǒng)計(jì)

          常用鏈接

          留言簿(6)

          隨筆分類(102)

          隨筆檔案(398)

          文章分類

          文章檔案(10)

          有趣網(wǎng)絡(luò)

          搜索

          積分與排名

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 绥宁县| 伽师县| 札达县| 武山县| 六盘水市| 东山县| 墨玉县| 仙游县| 灌南县| 信宜市| 成武县| 正宁县| 海淀区| 临湘市| 平凉市| 沁水县| 阿尔山市| 广昌县| 阿鲁科尔沁旗| 砚山县| 黄陵县| 通榆县| 娱乐| 体育| 贵溪市| 基隆市| 南郑县| 盘山县| 临高县| 苏尼特左旗| 沂源县| 天气| 荔浦县| 大兴区| 广德县| 微博| 探索| 晋中市| 长阳| 德安县| 溆浦县|