Beispiel #1
0
  public String getWordGroup() {
    ResultSet rs = null;

    if (sqltype.equals(SQLType.SQLite))
      rs = sqlite.query(Query.SELECT_GROUPNAME.value() + " name='" + word.getName() + "'");
    if (sqltype.equals(SQLType.MySQL))
      rs = mysql.query(Query.SELECT_GROUPNAME.value() + "name='" + word.getName() + "'");
    try {
      String s = null;
      while (rs.next()) {
        s = rs.getString(1);
      }
      return s;
    } catch (SQLException e) {
      plugin.sendErr(
          "SQLException while getting the word "
              + word.getName()
              + "'s group from the database. Error message: "
              + e.getMessage()
              + " ERROR CODE: "
              + e.getErrorCode());
      e.printStackTrace();
      return null;
    }
  }
Beispiel #2
0
 public String removeFromDB() {
   if (!wordExists()) {
     return String.valueOf(
         ChatColor.RED
             + "The word "
             + ChatColor.GOLD
             + word.getName()
             + ChatColor.RED
             + " does not exist!");
   } else {
     // ResultSet rs = null;
     if (sqltype.equals(SQLType.SQLite)) {
       sqlite.query(Query.DELETE_FROM.value() + "name='" + word.getName() + "'");
     }
     if (sqltype.equals(SQLType.MySQL)) {
       mysql.query(Query.DELETE_FROM.value() + "name='" + word.getName() + "'");
     }
     /*if (rs.equals(null)){
     	return String.valueOf(ChatColor.RED+"Error occured while deleting the word '"+word.getName()+"' Please check console for more info.");
     }*/
     return String.valueOf(
         ChatColor.GREEN
             + "Word "
             + ChatColor.GOLD
             + word.getName()
             + ChatColor.GREEN
             + " has been deleted.");
   }
 }
Beispiel #3
0
  public ArrayList<String> getWords() {
    ResultSet rs = null;
    ArrayList<String> w = new ArrayList<String>();

    if (sqltype.equals(SQLType.SQLite)) rs = sqlite.query(Query.SELECT_NAME.value());
    if (sqltype.equals(SQLType.MySQL)) rs = mysql.query(Query.SELECT_NAME.value());
    try {
      while (rs.next()) {
        w.add(rs.getString(1));
      }
      return w;
    } catch (SQLException e) {
      if (e.getMessage().contains("Illegal operation on empty result")) return null;
      plugin.send(
          "SQLException while getting words from the database. Error message: "
              + e.getMessage()
              + " ERROR CODE: "
              + e.getErrorCode());
      e.printStackTrace();
    }
    return null;
  }