ITPub博客

首页 > 数据库 > 数据库开发技术 > 存储过程

存储过程

原创 数据库开发技术 作者:jxmarvel 时间:2010-05-09 21:31:12 0 删除 编辑
由于之前比较忙,没有时间写,已经不知道多少天了~~呵呵,最近在研究存储过程,写了个sample的测试程序,写上来记一下。 CREATE PROCEDURE get_datetime (out cdate date, out ctime time ) P1: BEGIN VALUES CURRENT DATE INTO cdate; VALUES CURRENT TIME INTO ctime; END P1 有两个输出变量 可用select text from syscat.procedures where procname='xxx'来查看过程内容 用JDBC调用该存储过程的程序如下 public class Connect { public static void main(String[] args) throws ClassNotFoundException, SQLException{ Class.forName("com.ibm.db2.jcc.DB2Driver"); String url ="jdbc:db2://localhost:50000/sample"; Connection conn = DriverManager.getConnection( url,"db2admin","123"); String x,y; CallableStatement cs = conn.prepareCall("{call get_datetime(?,?)}"); cs.registerOutParameter(1, java.sql.Types.DATE); cs.registerOutParameter(2, java.sql.Types.TIME); Date date=null; Time time=null; try{ cs.execute(); date=cs.getDate(1); time=cs.getTime(2); System.out.print(date); }catch(Exception e){ e.printStackTrace(); } } }[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/11717161/viewspace-1033483/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 第二天
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-01-31

  • 博文量
    5
  • 访问量
    4970