通过bbosspersistent实现数据库存储过程的调用
来源:优易学  2011-12-17 12:16:47   【优易学:中国教育考试门户网】   资料下载   IT书店
  java片段:
  import com.frameworkset.common.poolman.CallableDBUtil;
  CallableDBUtil callableDBUtil = new CallableDBUtil();
  try
  {
  callableDBUtil.prepareCallable("{call test_p(?,?,?,?)}");
  callableDBUtil.setInt(1, 10);
  callableDBUtil.registerOutParameter(2, java.sql.Types.VARCHAR);
  callableDBUtil.registerOutParameter(3, java.sql.Types.VARCHAR);
  callableDBUtil.registerOutParameter(4, java.sql.Types.INTEGER);
  callableDBUtil.executeCallable();
  System.out.println("name1:" + callableDBUtil.getString(2));
  System.out.println("name2:" + callableDBUtil.getString(3));
  System.out.println("test:" + callableDBUtil.getInt(4));
  }
  catch(Exception e)
  {
  e.printStackTrace();
  }
  存储过程的定义脚本
  CREATE OR REPLACE PROCEDURE test_p(id in number,
  name out varchar2
  ,name1 out varchar2,test out number) IS
  /
  NAME: test
  PURPOSE:
  REVISIONS:
  Ver Date Author Description
  1.0 2008-10-27 1. Created this procedure.
  NOTES:
  Automatically available Auto Replace Keywords:
  Object Name: test
  Sysdate: 2008-10-27
  Date and Time: 2008-10-27, 17:05:33, and 2008-10-27 17:05:33
  Username: (set in TOAD Options, Procedure Editor)
  Table Name: (set in the "New PL/SQL Object" dialog)
  /
  BEGIN
  --tmpVar := 0;
  name := ’hello name’;
  name1 := ’hello name1’;
  test := id;
  insert into test(id,name) values(SEQ_TEST.nextval,’name1’);
  commit;
  EXCEPTION
  WHEN NO_DATA_FOUND THEN
  NULL;
  WHEN OTHERS THEN
  -- Consider logging the error and then re-raise
  RAISE;
  END test_p;
  /

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训