隨筆 - 4  文章 - 10  trackbacks - 0
          <2025年7月>
          293012345
          6789101112
          13141516171819
          20212223242526
          272829303112
          3456789

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          原文出處:http://www.aygfsteel.com/mlh123caoer/archive/2007/09/05/142885.html
          當你需要多次執行相同的SQL語句(一般情況下是update)但是使用不同的參數值時 ,可以使用
          PrepareStatement方法,舉例如下:

          Connection conn=null;
          PreparedStatement pst=null;
          String[] nm=new String[3];
          int[] nc=new int[3];
          ...
          try {
          nm[0]="Costescu",nm[1]="Alexandrescu",nm[2]="Popovici";
          nc[0]=234423;nc[1]=123344;nc[2]=534562;

          pst=conn.prepareStatement("UPDATE Table1 SET Nume=? WHERE Nr_cont=?");
          for(int i=0;i<=2;i++)
          {
          pst.setString(1,nm[i]);
          pst.setInt(2,nc[i]);
          pst.executeUpdate();
          }
          }catch (SQLException e){System.out.println(e.getMessage());}
          ...
          posted on 2007-09-05 16:19 冬天出走的豬 閱讀(217) 評論(0)  編輯  收藏 所屬分類: Database
          主站蜘蛛池模板: 彩票| 金沙县| 分宜县| 新田县| 莲花县| 延安市| 平陆县| 郓城县| 香格里拉县| 文登市| 民权县| 疏附县| 鹿泉市| 门头沟区| 饶河县| 南汇区| 陆河县| 深水埗区| 玉溪市| 扶沟县| 农安县| 红桥区| 前郭尔| 临高县| 赣州市| 禄丰县| 瑞安市| 周至县| 安徽省| 迁安市| 衡阳市| 太仆寺旗| 互助| 义马市| 武山县| 慈溪市| 望城县| 开封市| 扶沟县| 龙井市| 江西省|