您的位置:首页 > 编程语言 > Java开发

java调用储存过程的方法

2013-03-14 15:45 127 查看
java调用储存过程的方法

  public static Integer getStock(String strdate, Long orgId, Long productId){

  if(strdate==null||orgId==null||productId==null)

  throw new IllegalArgumentException();

  Integer stock = null;

  //DataAccess da = DataAccessFactory.create(BPMConstant.ERP_DATABASE);

  Connection conn=null;

  CallableStatement fun = null;

  try {

  String callSQL = "{?=call getstock(?,?,?)} ";

  //Connection conn = da.getConnection();

  conn=DBUtil.getConnection(BPMConstant.ERP_DATABASE);

  fun = conn.prepareCall(callSQL);

  fun.registerOutParameter(1, oracle.jdbc.OracleTypes.NUMBER);

  fun.setString(2, strdate);

  fun.setLong(3, orgId);

  fun.setLong(4, productId);

  fun.execute();

  stock = fun.getInt(1);

  }catch(Exception e){

  e.printStackTrace();

  }finally{

  DBUtil.closeCallableStatement(fun);

  DBUtil.closeConnection(conn);

  }

  return stock;

转自:http://www.cdtarena.com/javapx/201303/7954.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: