Java Code Examples for io.vertx.sqlclient.Query

The following examples show how to use io.vertx.sqlclient.Query. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: raml-module-builder   Source File: PostgresClientTest.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Query<RowSet<Row>> query(String s) {

  return new Query<RowSet<Row>>() {

    @Override
    public void execute(Handler<AsyncResult<RowSet<Row>>> handler) {
      if (s.startsWith("EXPLAIN") && failExplain) {
        handler.handle(Future.failedFuture("failExplain"));
      } else if (s.startsWith("COUNT ") && asyncResult.succeeded()) {
        List<String> columnNames = new LinkedList<>();
        columnNames.add("COUNT");
        RowDesc rowDesc = new RowDesc(columnNames);
        Row row = new RowImpl(rowDesc);
        row.addInteger(asyncResult.result().size());
        List<Row> rows = new LinkedList<>();
        rows.add(row);
        RowSet rowSet = new LocalRowSet(asyncResult.result().size()).withColumns(columnNames).withRows(rows);
        handler.handle(Future.succeededFuture(rowSet));
      } else {
        handler.handle(asyncResult);
      }
    }

    @Override
    public <R> Query<SqlResult<R>> collecting(Collector<Row, ?, R> collector) {
      return null;
    }

    @Override
    public <U> Query<RowSet<U>> mapping(Function<Row, U> function) {
      return null;
    }
  };
}
 
Example 2
Source Project: quarkus   Source File: ThreadLocalPool.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Query<RowSet<Row>> query(String sql) {
    return pool().query(sql);
}
 
Example 3
Source Project: vertx-sql-client   Source File: TemplateBuilderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Query<RowSet<Row>> query(String sql) {
  throw new UnsupportedOperationException();
}
 
Example 4
Source Project: vertx-sql-client   Source File: QueryBase.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public <U> Query<SqlResult<U>> collecting(Collector<Row, ?, U> collector) {
  Objects.requireNonNull(collector, "Supplied collector must not be null");
  return copy(new QueryExecutor<>(builder.tracer(), builder.metrics(), SqlResultImpl::new, collector));
}
 
Example 5
Source Project: vertx-sql-client   Source File: QueryBase.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public <U> Query<RowSet<U>> mapping(Function<Row, U> mapper) {
  Objects.requireNonNull(mapper, "Supplied mapper must not be null");
  return copy(new QueryExecutor<>(builder.tracer(), builder.metrics(), RowSetImpl.factory(), RowSetImpl.collector(mapper)));
}
 
Example 6
Source Project: vertx-sql-client   Source File: SqlClientBase.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Query<RowSet<Row>> query(String sql) {
  QueryExecutor<RowSet<Row>, RowSetImpl<Row>, RowSet<Row>> builder = new QueryExecutor<>(tracer, metrics, RowSetImpl.FACTORY, RowSetImpl.COLLECTOR);
  return new QueryImpl<>(autoCommit(), false, sql, builder);
}