打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
JDBC调用存储过程
  1. public int addORDelAgentPerson(String strTableID,String strUserID,String strAgentID,String strType)throws Exception{  
  2.        Connection conn= null;  
  3.        CallableStatement cbst = null;  
  4.        ResultSet rs = null;  
  5.        String procedure = "{call SP_SetDevolvePerson(?,?,?,?)} ";  
  6.        //int count = 0;  
  7.        try{  
  8.            conn = jbpu.getConnection();  
  9.            conn.setAutoCommit(false);  
  10.            cbst = conn.prepareCall(procedure);  
  11.            cbst.setString(1, strTableID);  
  12.            cbst.setString(2, strUserID);  
  13.            cbst.setString(3, strAgentID);  
  14.            cbst.setString(4, strType);  
  15.            //count = cbst.executeUpdate();  
  16.            cbst.executeUpdate();  
  17.            conn.commit();  
  18.            return 1;  
  19.        }catch(Exception e){  
  20.            conn.rollback();  
  21.            e.printStackTrace();  
  22.            return 0;  
  23.        }finally{  
  24.            jbpu.close(rs, cbst, conn);  
  25.        }  
  26.    }  

注:

1、JDBC通过CallableStatement 接口调用存储过程;

2、jbpu是封装好的一个jdbc工具类实例;

3、jdbc传参的起始序号为1;

4、return 0或1,只是标识是否执行成功,也可用其它方式标识。

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
jdbc调用oracle的有输出参数的存储过程
JDBC连接执行MySQL存储过程报权限错误
优化存储过程
存储过程
JDBC调用MySQL5存储过程
JDBC 驱动程序调用存储过程
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服