@Override
  public boolean update(PostingLocation postingLocation) throws SQLException {
    if (postingLocation == null) {
      return false;
    }

    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;

    try {
      connection = this.daoFactory.getConnection();

      final Object[] values = {
        postingLocation.getEmail(), postingLocation.getActive(), postingLocation.getLocation_fk()
      };

      preparedStatement = DAOUtil.prepareStatement(connection, this.SQL_UPDATE, false, values);

      Globals.crawlerLogManager.writeLog(preparedStatement.toString());

      preparedStatement.executeUpdate();

      return true;
    } catch (final SQLException e) {
      Globals.crawlerLogManager.writeLog(
          "Fails to update email "
              + postingLocation.getEmail()
              + " in posting_location for id "
              + postingLocation.getLocation_fk());
      Globals.crawlerLogManager.writeLog(e.getMessage());

      return false;
    } finally {
      DAOUtil.close(connection, preparedStatement, resultSet);
    }
  }
  private PostingLocation constructPostingLocationObject(ResultSet resultSet) throws SQLException {
    final PostingLocation location = new PostingLocation();

    location.setState(resultSet.getString("state"));
    if (resultSet.wasNull()) {
      location.setState(null);
    }

    location.setCity(resultSet.getString("city"));
    if (resultSet.wasNull()) {
      location.setCity(null);
    }

    location.setLatitude(resultSet.getString("latitude"));
    if (resultSet.wasNull()) {
      location.setLatitude(null);
    }

    location.setLongitude(resultSet.getString("longitude"));
    if (resultSet.wasNull()) {
      location.setLongitude(null);
    }

    location.setLocation_fk(resultSet.getInt("location_fk"));
    if (resultSet.wasNull()) {
      location.setLocation_fk(null);
    }

    location.setLocation_link_fk(resultSet.getInt("location_link_fk"));
    if (resultSet.wasNull()) {
      location.setLocation_link_fk(null);
    }

    location.setDatePosted(resultSet.getString("datePosted"));
    if (resultSet.wasNull()) {
      location.setDatePosted(null);
    }

    location.setTimePosted(resultSet.getString("timePosted"));
    if (resultSet.wasNull()) {
      location.setTimePosted(null);
    }

    location.setPosting_body(resultSet.getString("posting_body"));
    if (resultSet.wasNull()) {
      location.setPosting_body(null);
    }

    location.setTitle(resultSet.getString("title"));
    if (resultSet.wasNull()) {
      location.setTitle(null);
    }

    location.setAlt_quantities(resultSet.getString("alt_quantities"));
    if (resultSet.wasNull()) {
      location.setAlt_quantities(null);
    }

    location.setAlt_prices(resultSet.getString("alt_prices"));
    if (resultSet.wasNull()) {
      location.setAlt_prices(null);
    }

    location.setUrl(resultSet.getString("url"));
    if (resultSet.wasNull()) {
      location.setUrl(null);
    }

    location.setActive(resultSet.getInt("active"));
    if (resultSet.wasNull()) {
      location.setActive(null);
    }

    location.setEmail(resultSet.getString("email"));
    if (resultSet.wasNull()) {
      location.setEmail(null);
    }

    return location;
  }
  @Override
  public boolean create(PostingLocation location) throws SQLException {
    if (!location.isValid()) {
      return false;
    }

    Connection connection = null;
    PreparedStatement preparedStatement = null;
    ResultSet resultSet = null;

    try {
      connection = this.daoFactory.getConnection();

      final Object[] values = {
        location.getState(),
        location.getCity(),
        location.getLatitude(),
        location.getLongitude(),
        location.getLocation_fk(),
        location.getLocation_link_fk(),
        location.getDatePosted(),
        location.getTimePosted(),
        location.getPosting_body(),
        location.getTitle(),
        location.getUrl(),
        location.getActive(),
        location.getEmail()
      };

      preparedStatement = DAOUtil.prepareStatement(connection, this.SQL_INSERT, false, values);

      Globals.crawlerLogManager.writeLog(preparedStatement.toString());

      preparedStatement.executeUpdate();

      return true;
    } catch (final SQLException e) {
      Globals.crawlerLogManager.writeLog("Insert into table posting_location fails");
      Globals.crawlerLogManager.writeLog(e.getMessage());

      return false;
    } finally {
      DAOUtil.close(connection, preparedStatement, resultSet);
    }
  }