Exemple #1
0
  public boolean addEHVSS(EHVSS ehvss, ErrorBean errorBean) {
    ArrayList<EHVSS> ehvssList = new ArrayList<EHVSS>();
    boolean added;
    try {
      Connection connection = DatabaseConnection.getConnection("mms_new");
      ehvssList = getByCode(ehvss.getCode());
      if (ehvssList == null || ehvssList.size() == 0) {
        PreparedStatement ps =
            connection.prepareStatement(
                "insert into EHVSS(code, name, location, region, circle, division) VALUES(?,?,?,?,?,?)");
        ps.setString(1, ehvss.getCode());
        ps.setString(2, ehvss.getName());
        ps.setString(3, "DUMMY");
        ps.setString(4, ehvss.getRegion());
        ps.setString(5, "DUMMY");
        ps.setString(6, "DUMMY");
        ps.executeUpdate();
        added = true;
        ps.close();

      } else {
        errorBean.setErrorMessage("EHVSS Code Already Exist. Please provide Different EHVSS Code");
        added = false;
      }
    } catch (SQLException e) {
      added = false;
      System.out.println("Exception in [updateUser]" + e);
    }
    return added;
  }
Exemple #2
0
  public EHVSS addEHVSS(EHVSS ehvss) {
    try {
      Connection connection = DatabaseConnection.getConnection("mms_new");
      PreparedStatement ps =
          connection.prepareStatement(
              "insert into EHVSS(code, name, location, region, circle, division) VALUES(?,?,?,?,?,?)");
      ps.setString(1, ehvss.getCode());
      ps.setString(2, ehvss.getName());
      ps.setString(3, "DUMMY");
      ps.setString(4, ehvss.getRegion());
      ps.setString(5, "DUMMY");
      ps.setString(6, "DUMMY");
      ps.executeUpdate();
      ResultSet resultSet = ps.executeQuery("select last_insert_id() as 'id'");
      resultSet.next();
      int id = resultSet.getInt("id");
      ehvss.setId(String.valueOf(id));
      resultSet.close();
      ps.close();

    } catch (SQLException e) {
      System.out.println("Exception in [addEHVSS(EHVSS)]" + e);
    }
    return ehvss;
  }
Exemple #3
0
  public EHVSS updateEHVSS(EHVSS ehvss) {
    try {
      Connection connection = DatabaseConnection.getConnection("mms_new");
      PreparedStatement ps =
          connection.prepareStatement(
              "update EHVSS set code=?,name=?,location=?,region=?,circle=?,division=? where id=?");
      ps.setString(1, ehvss.getCode());
      ps.setString(2, ehvss.getName());
      ps.setString(3, "DUMMY");
      ps.setString(4, ehvss.getRegion());
      ps.setString(5, "DUMMY");
      ps.setString(6, "DUMMY");
      ps.setInt(7, Integer.parseInt(ehvss.getId()));
      ps.executeUpdate();
      ps.close();

    } catch (SQLException e) {
      System.out.println("Exception in [updateEHVSS(EHVSS)]" + e);
    }
    return ehvss;
  }