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

常用链接

留言簿(1)

随笔分类(146)

随笔档案(147)

文章分类(28)

文章档案(28)

喜欢的Blog

搜索

  •  

最新评论

阅读排行榜

评论排行榜

---------------------创建存储过程---------------------
1-----------------存储过程---------------------
2create procedure FindCusts
3@cust varchar(10)
4as
5select customerid from orders where customerid 
6like '%'+@cust+'%'
7---------------执行---------------------------
8execute FindCusts 'alfki'
--------------在Java中调用--------------------
 1import java.sql.*;
 2
 3public class ProcedureTest {
 4    public static void main(String args[]) throws Exception {
 5        //加载驱动
 6        DriverManager.registerDriver(new sun.jdbc.odbc.JdbcOdbcDriver());
 7        //获得连接
 8        Connection conn = DriverManager.getConnection("jdbc:odbc:mydata""sa",
 9                "");
10        //创建存储过程的对象
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 飞翔天使 阅读(419) 评论(0)  编辑  收藏 所属分类: java

只有注册用户登录后才能发表评论。


网站导航: