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

          常用鏈接

          留言簿(1)

          隨筆檔案

          文章分類

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          原文出處:http://www.aygfsteel.com/mlh123caoer/archive/2007/09/05/142885.html
          當你需要多次執(zhí)行相同的SQL語句(一般情況下是update)但是使用不同的參數(shù)值時 ,可以使用
          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
          主站蜘蛛池模板: 吕梁市| 新乡县| 鹤峰县| 元阳县| 建德市| 开江县| 古蔺县| 太和县| 奉新县| 手游| 绍兴县| 双流县| 乌鲁木齐市| 兴山县| 康乐县| 集安市| 南通市| 山东省| 周宁县| 驻马店市| 田阳县| 岳阳县| 崇明县| 寻甸| 万山特区| 辰溪县| 永城市| 长乐市| 包头市| 两当县| 全椒县| 和田市| 桂阳县| 通道| 乐陵市| 周至县| 肃南| 乌拉特中旗| 玉门市| 鸡东县| 临朐县|