Vert.x: retrieve records from database
<p>I have method called <code>selectAll</code> which has to return records selected from database, but when I want to return them as String it doesn't allow it and gives me:</p>

<p><code>Local variable S defined in an enclosing scope must be final or effectively final.</code></p>

<p>I tried to add final to my String but it stills the same.</p>

<p>Here is my <code>selectAll()</code> method: </p>

<pre><code>public String selectAll(String table, String order) {
  String S;
  S = "";
  this.getCnx().getConnection(res -&gt; {
    if (res.succeeded()) {
      SQLConnection connection = res.result();
      connection.queryWithParams(ReqSql.SELECT_ALL, new JsonArray().add(table).add(order), (ar) -&gt; {
        if (ar.failed()) {
          this.sendError(500, response);
        } else {
          JsonArray arr = new JsonArray();
          ar.result().getRows().forEach(arr::add);
          S = ar.result().getRows().toString();
          response.putHeader("content-type", "application/json").end(arr.encode());
        }
      });
    }
  });
}

public AsyncSQLClient getCnx(){
     JsonObject mySQLClientConfig = new JsonObject()
            .put("host", "localhost")
            .put("database", "test")
            .put("username", "test")
            .put("password", "test")                    
            .put("port", 3306);

     return MySQLClient.createShared(vertx, mySQLClientConfig);
}
</code></pre>

<p>And I create another class for my requests: </p>

<pre><code>public class ReqSql {
  public static final String SELECT_ALL = "SELECT * FROM ? ORDER BY ? ASC";
}
</code></pre>

<p>Regards.</p>