@Override
 public void replaceEntries(final List<Entry> batch) throws IOException {
   if (batch.size() == 0) {
     return;
   }
   final Entry entry0 = batch.getElementAt(0);
   final String table_name = this.sql_table_name;
   final List<String> keys = Collections.newList();
   final String stm = "REPLACE " + table_name + " " + this.paramString(entry0, keys, "(", ")");
   final MySQLConnection connection = this.db.obtainConnection();
   connection.checkIsOpen();
   try {
     final Connection mysql_connection = connection.getConnection();
     final PreparedStatement statement = mysql_connection.prepareStatement(stm);
     for (int b = 0; b < batch.size(); b++) {
       final Entry entry = batch.getElementAt(b);
       for (int i = 0; i < keys.size(); i++) {
         final String key = keys.getElementAt(i);
         final String value = entry.getValue(key);
         statement.setString(i + 1, value);
       }
       statement.addBatch();
     }
     statement.executeBatch();
   } catch (final SQLException e) {
     e.printStackTrace();
     throw new IOException(e);
   } finally {
     this.db.releaseConnection(connection);
   }
 }
  @Override
  public void addEntry(final Entry entry) throws IOException {

    final String table_name = this.sql_table_name;
    final List<String> keys = Collections.newList();
    final String stm = "INSERT INTO " + table_name + " " + this.paramString(entry, keys, "(", ")");
    final MySQLConnection connection = this.db.obtainConnection();
    connection.checkIsOpen();
    try {
      final Connection mysql_connection = connection.getConnection();

      final PreparedStatement statement = mysql_connection.prepareStatement(stm);

      for (int i = 0; i < keys.size(); i++) {
        final String key = keys.getElementAt(i);
        final String value = entry.getValue(key);
        statement.setString(i + 1, value);
      }

      statement.execute();
    } catch (final SQLException e) {
      e.printStackTrace();
      throw new IOException(e);
    } finally {
      this.db.releaseConnection(connection);
    }
  }
  public static void main(final String[] args) throws IOException, URISyntaxException {
    DesktopSetup.deploy();
    Json.installComponent("com.jfixby.cmns.adopted.gdx.json.RedJson");

    final File words_folder = LocalFileSystem.ApplicationHome().child("words");
    final ChildrenList words_files = words_folder.listDirectChildren();
    final WordsSorter sorter = new WordsSorter(false);
    for (int i = 0; i < words_files.size(); i++) {
      final File file = words_files.getElementAt(i);
      final String file_name = file.getName();
      if (file_name.startsWith("#")) {
        continue;
      }
      L.d("reading", file_name);
      final String data = file.readToString();
      L.d("parsing", file_name);
      final WordCollectorFile content = Json.deserializeFromString(WordCollectorFile.class, data);

      final List<WordCollector> split = Collections.newList(content.values);
      L.d("   adding", split.size());
      sorter.addOthers(split);
    }
    sorter.filter(1);
    sorter.sort();

    // sorter.print();

    final Collection<WordCollector> terms_list = sorter.list();
    terms_list.print("terms_list", 0, 500);
    final Random random = new Random();

    final int EXTRACTIONS = 100;
    final int NUMBER_OF_TERMS = 8;

    for (int i = 0; ; i++) {
      final List<String> batch = Collections.newList();
      for (int k = 0; k < EXTRACTIONS; k++) {
        final String request = generateRequest(NUMBER_OF_TERMS, terms_list, random);
        batch.add(request);
      }
      batch.print("batch generated");
      for (int k = 0; k < batch.size(); k++) {
        final String request = batch.getElementAt(k);
        final String request_url = template + request.replaceAll(" ", "+");
        L.d(request, request_url);
        openUrl(request_url);
        Sys.sleep(10 * 1000);
      }
    }
  }