存储过程

Session session =this.getSession(); 
  CallableStatement call;
  String sql = "";
  try {
   call = session.connection().prepareCall("{Call MKTMB_STATISTICS.PROC_MOBILE_STATISTICS(?,?,?,?,?,?,?)}");
   call.setString(1, startTime);// 这里为传入参数
   call.setString(2, endTime);
   call.setString(3, regionID);
   call.setInt(4, type);
   call.setInt(5, levels);  
   call.registerOutParameter(6, OracleTypes.INTEGER);
   call.registerOutParameter(7, OracleTypes.VARCHAR);
   call.execute();
   // 0成功/1失败
   if(call.getInt(6)== 0 ){
    sql = call.getString(7);

   }else{
    throw new MKTMBException("DAO层存储过程查询失败!");
   };
   call.close();
   return sql;
  } catch (HibernateException e) {
   e.printStackTrace();
   return null;
  } catch (SQLException e) {
   e.printStackTrace();
   return null;
  }  

你可能感兴趣的:(DAO,sql,mobile)