调用存储过程,java中通过bboss persistent实现数据库存储过程的调用(位置变量绑定)

本文介绍如何使用Java的BBoss框架调用数据库存储过程,并提供了一个具体的例子,包括存储过程定义及Java代码实现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

bboss persistent下载地址

https://sourceforge.net/project/showfiles.php?group_id=238653&package_id=302766&release_id=647144

  1.  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();
  }

 

2.存储过程的定义脚本

 

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;

 

/

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值