隨筆 - 147  文章 - 71  trackbacks - 0
          <2009年2月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          1234567

          常用鏈接

          留言簿(1)

          隨筆分類(146)

          隨筆檔案(147)

          文章分類(28)

          文章檔案(28)

          喜歡的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          ---------------------創(chuàng)建存儲過程---------------------
          1-----------------存儲過程---------------------
          2create procedure FindCusts
          3@cust varchar(10)
          4as
          5select customerid from orders where customerid 
          6like '%'+@cust+'%'
          7---------------執(zhí)行---------------------------
          8execute FindCusts 'alfki'
          --------------在Java中調(diào)用--------------------
           1import java.sql.*;
           2
           3public class ProcedureTest {
           4    public static void main(String args[]) throws Exception {
           5        //加載驅(qū)動
           6        DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
           7        //獲得連接
           8        Connection conn = DriverManager.getConnection("jdbc:odbc:mydata""sa",
           9                "");
          10        //創(chuàng)建存儲過程的對象
          11        CallableStatement c = conn.prepareCall("{call FindCusts(?)}");
          12        c.setString(1"Tom");
          13        ResultSet rs = c.executeQuery();
          14        while (rs.next()) {
          15            String cust = rs.getString("customerid");
          16            System.out.println(cust);
          17        }

          18        c.close();
          19    }

          20}
          posted on 2009-02-15 10:43 飛翔天使 閱讀(438) 評論(0)  編輯  收藏 所屬分類: java
          主站蜘蛛池模板: 石林| 樟树市| 韩城市| 蚌埠市| 霞浦县| 闻喜县| 兰西县| 恩平市| 南投市| 江阴市| 罗山县| 禄丰县| 昂仁县| 南部县| 精河县| 香港| 中西区| 安平县| 澎湖县| 扎兰屯市| 徐汇区| 措美县| 永胜县| 禹州市| 房产| 威远县| 集贤县| 曲水县| 海安县| 平塘县| 东乡县| 庆城县| 洛阳市| 宝兴县| 孟村| 文化| 锡林浩特市| 巫溪县| 富源县| 资中县| 辉县市|