薄雾倾城

导航

关于JAVA调用oracle存储过程

 Session s = this.getSession();
  CallableStatement cstm = null;
  String flag = null;
  try {
   cstm = ((SessionImplementor) s)
     .getBatcher()
     .prepareBatchCallableStatement(
       "call proc_applyfeelist(?,?,?,?)");
   cstm.setString(1, applyfee.getSubcompany());
   cstm.setDate(2, DateUtils
     .toHibernateDate(applyfee.getStartdate()));
   cstm.setDate(3, DateUtils
     .toHibernateDate(applyfee.getEnddate()));
   cstm.registerOutParameter(4, Types.CHAR);//返回值
   cstm.execute();
   flag = cstm.getString(4);//获取返回值
  } catch (SQLException ex2) {
   System.out.println(ex2.getMessage());
   FormatUtils.throwSQLException(ex2.getMessage());
  } finally { // 关闭cstm
   try {
    if (cstm != null)
     cstm.close();
   } catch (SQLException e) {
    throw new BusinessException(e);
   }
  }

posted on 2011-09-26 17:27  若菲  阅读(251)  评论(0编辑  收藏  举报