public void addAffectiveFeature(AffectiveFeature af) throws Exception {
    if (af == null) {
      logger.error("AffectiveFeature is null.");
      return;
    }

    String query = "INSERT INTO affective_features (feature, word) VALUES (?, ?) ";
    PreparedStatement pstmt = null;

    try {
      pstmt = connect.prepareStatement(query);

      for (String word : af.getAffectiveWordList()) {
        pstmt.setString(1, af.getAffectiveCategory());
        pstmt.setString(2, word);

        try {
          pstmt.executeUpdate();
        } catch (Exception e) {
          if (e.getMessage().contains("Duplicate entry")) {
            logger.debug("Duplicate entry found: " + e.getMessage());
          } else {
            throw e;
          }
        }
      }

      this.connect.commit();
    } finally {
      if (pstmt != null) {
        pstmt.close();
      }
    }
  }