コード例 #1
0
  @Override
  public boolean insert(TravelAgent agent) {
    boolean bool = false;

    try {
      this.pStat = this.conn.prepareStatement(INSERT);
      this.pStat.setString(1, agent.getId());
      this.pStat.setString(2, agent.getName());
      this.pStat.setString(3, agent.getAlamat());
      this.pStat.setString(4, agent.getProvinsi());
      this.pStat.setString(5, agent.getNegara());
      this.pStat.setString(6, agent.getPhone());
      this.pStat.setString(7, agent.getFax());
      this.pStat.setString(8, agent.getEmail());
      this.pStat.setString(9, agent.getWebsite());
      this.pStat.setDouble(10, agent.getFee());
      this.pStat.setInt(11, agent.getStatus());
      this.pStat.setString(12, agent.getContactName());
      this.pStat.setString(13, agent.getContactPosisi());
      this.pStat.setString(14, agent.getContactPhone());
      if (this.pStat.executeUpdate() == 1) {
        bool = true;
      } else {
        bool = false;
      }

    } catch (SQLException ex) {
      System.out.println(ex.getMessage());
    }
    return bool;
  }
コード例 #2
0
  @Override
  public boolean update(String id, TravelAgent agent) {
    try {
      this.pStat = this.conn.prepareStatement(UPDATE);
      this.pStat.setString(1, agent.getName());
      this.pStat.setString(2, agent.getAlamat());
      this.pStat.setString(3, agent.getProvinsi());
      this.pStat.setString(4, agent.getNegara());
      this.pStat.setString(5, agent.getPhone());
      this.pStat.setString(6, agent.getFax());
      this.pStat.setString(7, agent.getEmail());
      this.pStat.setString(8, agent.getWebsite());
      this.pStat.setDouble(9, agent.getFee());
      this.pStat.setInt(10, agent.getStatus());
      this.pStat.setString(11, agent.getContactName());
      this.pStat.setString(12, agent.getContactPosisi());
      this.pStat.setString(13, agent.getContactPhone());
      this.pStat.setString(14, id);
      if (this.pStat.executeUpdate() == 1) {
        return true;
      } else {
        return false;
      }
    } catch (SQLException e) {

    }
    return false;
  }