io.vertx.sqlclient.Query Java Examples

The following examples show how to use io.vertx.sqlclient.Query. 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 File: PostgresClientTest.java    From raml-module-builder with 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 File: ThreadLocalPool.java    From quarkus with 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 File: TemplateBuilderTest.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public Query<RowSet<Row>> query(String sql) {
  throw new UnsupportedOperationException();
}
 
Example #4
Source File: QueryBase.java    From vertx-sql-client with 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 File: QueryBase.java    From vertx-sql-client with 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 File: SqlClientBase.java    From vertx-sql-client with 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);
}