示例#1
0
  /** get utilisatuer par type et categorie */
  public ArrayList<Ouvrage> getOuvrage(DataSource ds, int type, int categorie) {

    ArrayList<Ouvrage> list = new ArrayList<Ouvrage>();

    try {
      con = ds.getConnection();
      stm =
          con.prepareStatement(
              "SELECT * FROM ouvrage WHERE CategorieOuvrageid=? AND OuvrageTypeid=?");
      stm.setInt(1, categorie); // type user prof 1
      stm.setInt(2, type);
      rs = stm.executeQuery();

      BeanProcessor bp = new BeanProcessor();
      list = (ArrayList) bp.toBeanList(rs, Ouvrage.class);

      con.close();
      rs.close();

    } catch (SQLException ex) {
      Logger.getLogger(UtilisateurModele.class.getName()).log(Level.SEVERE, null, ex);
    }

    return list;
  }
示例#2
0
  /** @see com.yahoo.petermwenda83.persistence.guardian.SchoolParentsDAO#getParentList() */
  @Override
  public List<StudentParent> getParentList() {
    List<StudentParent> list = null;
    try (Connection conn = dbutils.getConnection();
        PreparedStatement pstmt = conn.prepareStatement("SELECT * FROM StudentParent;");
        ResultSet rset = pstmt.executeQuery(); ) {

      list = beanProcessor.toBeanList(rset, StudentParent.class);

    } catch (SQLException e) {
      logger.error("SQL Exception when getting Parent List");
      logger.error(ExceptionUtils.getStackTrace(e));
      System.out.println(ExceptionUtils.getStackTrace(e));
    }
    return list;
  }
示例#3
0
  /**
   * @see com.yahoo.petermwenda83.persistence.guardian.SchoolParentsDAO#getParent(java.lang.String)
   */
  @Override
  public StudentParent getParent(String studentUuid) {
    StudentParent studentParent = null;
    ResultSet rset = null;

    try (Connection conn = dbutils.getConnection();
        PreparedStatement pstmt =
            conn.prepareStatement("SELECT * FROM studentParent" + " WHERE studentUuid =?;"); ) {
      pstmt.setString(1, studentUuid);
      rset = pstmt.executeQuery();
      while (rset.next()) {
        studentParent = beanProcessor.toBean(rset, StudentParent.class);
      }

    } catch (SQLException e) {
      logger.error("SQL Exception trying to get studentParent with studentuuid: " + studentUuid);
      logger.error(ExceptionUtils.getStackTrace(e));
      System.out.println(ExceptionUtils.getStackTrace(e));
    }
    return studentParent;
  }