Exemple #1
0
  public BeanTest[] getViewAllTestForUser(String CUserName, String CCatName) throws SQLException {
    ArrayList<BeanTest> test2 = new ArrayList<>();

    PreparedStatement statement =
        connection.prepareStatement(Constants.sqlCommands.getViewAllTestForUserSql);

    statement.setString(1, CCatName);
    statement.setString(2, CUserName);
    ResultSet rs = statement.executeQuery();

    BeanTest objTest;

    while (rs.next()) {

      objTest = new BeanTest();
      objTest.setTestName(rs.getString(1));
      objTest.setTestDate(rs.getDate(2));
      objTest.setTestDuration(rs.getInt(3));
      objTest.setTestId(rs.getInt(4));

      if (rs.getDouble(5) == 0.0 && rs.getInt(6) == 0 && rs.getInt(7) == 0)
        objTest.setTestDesc("Not Attempted");
      else objTest.setTestDesc("Attempted");

      test2.add(objTest);
    }

    rs.close();
    statement.close();
    // connection.close();
    return test2.toArray(new BeanTest[test2.size()]);
  }
Exemple #2
0
  public BeanTest[] getNotRegisterTestForUser(String CUserName, String CCatName)
      throws SQLException {
    ArrayList<BeanTest> test1 = new ArrayList<>();

    PreparedStatement statement =
        connection.prepareStatement(Constants.sqlCommands.getNotRegisterTestForUserSql);
    statement.setString(1, CCatName);
    statement.setString(2, CUserName);
    ResultSet rs = statement.executeQuery();

    BeanTest objTest;

    while (rs.next()) {
      objTest = new BeanTest();
      objTest.setTestName(rs.getString(1));
      objTest.setTestDate(rs.getDate(2));
      objTest.setTestDuration(rs.getInt(3));
      objTest.setTestId(rs.getInt(4));
      test1.add(objTest);
    }
    rs.close();
    statement.close();

    return test1.toArray(new BeanTest[test1.size()]);
  }