title: How to get data out of Postgres db using Vertx
body: <p>Hello I am trying to access a Postgresql database using vertx.
  The code I used to access the database is as follows.</p>
  <pre><code>public Future&lt;String&gt; readMemberTotal(String month, String time) {
  return clientPostgreSql
    .preparedQuery(&quot;SELECT price_ty_id, unit_price FROM price_units AS pu INNER JOIN price_types AS pt ON pt.id = pu.price_ty_id INNER JOIN prices AS p on pu.price_set_id = p.id WHERE pu.id=2 AND p.ty='MEMBER' AND month=$1 AND time=$2&quot;)
    .execute(Tuple.of(month, time))
    .compose(ar -&gt; {
      Promise&lt;String&gt; promise = Promise.promise();
      StringBuilder returnVal =new StringBuilder();
      ar.forEach(row -&gt; {
        String priceTyId = row.getString(&quot;price_ty_id&quot;);
        Integer unitPrice = Integer.parseInt(row.getString(&quot;unit_price&quot;))*10;
  
        returnVal.append(priceTyId);
        returnVal.append(unitPrice);
  
      });
      promise.complete(returnVal.toString());
      return promise.future();
    });
  </code></pre>
  <p>}</p>
  <p>And</p>
  <pre><code>public Future&lt;String&gt; getOperatingTime(String chargerId){
  return clientPostgreSql
    .preparedQuery(&quot;SELECT ormpm FROM chargers WHERE id =$1&quot;)
    .execute(Tuple.of(chargerId))
    .map(ar -&gt;{
      StringBuilder returnVal =new StringBuilder();
      ar.forEach(row -&gt;{
        returnVal.append(row.getString(&quot;ormpm&quot;));
      });
      log.info(&quot;return value is:&quot; + returnVal.toString());
      return returnVal.toString();
    })
    .onSuccess(ar-&gt; log.debug(&quot;operating time succeeded&quot;))
    .onFailure(er-&gt; log.debug(&quot;operating time failed&quot;));
  </code></pre>
  <p>}</p>
  <p>And in another class I am using these two methods</p>
  <pre><code>        List&lt;Future&gt;futureList = Arrays.asList(chargerRepository.getOperatingTime(chargerId.toString()));
          for(int i=0; i&lt;24; i++){
            futureList.add(chargerRepository.readMemberTotal(&quot;1&quot;, String.valueOf(i)));
           }
          log.info(&quot;futureList length&quot; + futureList.size());
          CompositeFuture c = CompositeFuture.all(futureList);
  </code></pre>
  <p>The log seems to print 'operating time failed' and fails to print out the length of futureList.</p>
  <p>When I run this on the db it seems to work fine.
  It would be deeply appreciated if anyone could point out what I am doing wrong.
  Thank you in advance!</p>