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) 評(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)論排行榜

          主站蜘蛛池模板: 嘉荫县| 五家渠市| 石渠县| 安宁市| 桐梓县| 开鲁县| 旬阳县| 康乐县| 虹口区| 塘沽区| 页游| 通渭县| 锦屏县| 新丰县| 睢宁县| 聊城市| 上杭县| 玛多县| 德令哈市| 永昌县| 呼伦贝尔市| 莱阳市| 澳门| 鄱阳县| 夏邑县| 博爱县| 景洪市| 榆林市| 壶关县| 新余市| 鹤山市| 襄樊市| 普定县| 龙州县| 延津县| 海城市| 兰州市| 淅川县| 克什克腾旗| 白城市| 台南市|