示例#1
0
  @Override
  public List<Result> getResult(Examination examination, User user) throws DatabaseException {
    List<Result> resultList = null;
    Connection connection = null;
    PreparedStatement statement = null;
    ResultSet rs = null;

    try {
      connection = DBUtility.getConnection();
      statement = connection.prepareStatement(SELECT_BY_EXAM_USER);
      statement.setInt(1, examination.getExaminationId());
      statement.setInt(2, user.getUserId());
      rs = statement.executeQuery();

      resultList = createResultObject(rs);

    } catch (ClassNotFoundException ex) {
      LOG.log(Level.SEVERE, null, ex);
      throw new DatabaseException(ex);
    } catch (SQLException ex) {
      LOG.log(Level.SEVERE, null, ex);
      throw new DatabaseException(ex);
    } finally {
      DBUtility.close(rs);
      DBUtility.close(statement);
      DBUtility.close(connection);
    }

    return resultList;
  }