io.vertx.sqlclient.PreparedQuery Java Examples

The following examples show how to use io.vertx.sqlclient.PreparedQuery. 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: ProcessUpdate.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void processConnection(int queries, long conId, long seqCode) {
	
	//only process after we have the prepared statements built.
	PreparedQuery query = selectableQuery();
	if (query==null) {
		return;
	}
	
	PreparedQuery update= updateQuery();
	if (update==null) {
		return;
	}
	
	List<ResultObject> objs = new ArrayList<ResultObject>(queries);
	int q = queries;
	while (--q >= 0) {
			processSingleUpdate(queries, conId, seqCode, objs, query, update);
	
	}
}
 
Example #2
Source File: SqlTemplateImpl.java    From vertx-sql-client with Apache License 2.0 5 votes vote down vote up
public SqlTemplateImpl(SqlClient client,
                       SqlTemplate sqlTemplate,
                       Function<PreparedQuery<RowSet<Row>>,
                       PreparedQuery<R>> queryMapper,
                       Function<T, Map<String, Object>> paramsMapper) {
  this.client = client;
  this.sqlTemplate = sqlTemplate;
  this.queryMapper = queryMapper;
  this.paramsMapper = paramsMapper;
}
 
Example #3
Source File: ProcessUpdate.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private PreparedQuery selectableQuery() {
	
	if (null!=selectQuery || building) {
		return selectQuery;		
	} else {
		building = true;
		pm.pool().getConnection(h -> {
			
			if (h.succeeded()) {
				SqlConnection connection = h.result();
				
				connection.prepare("SELECT * FROM world WHERE id=$1", ph -> {
					if (ph.succeeded()) {							
						selectQuery = ph.result();	
						
						building = false;
						if (updateQuery==null) {
							updateQuery();
						}
						
					} else {							
						ph.cause().printStackTrace();
					}
				});
				
				connection.close();
			} else {
				h.cause().printStackTrace();
			}
		});
		return null;
	}
}
 
Example #4
Source File: ProcessUpdate.java    From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private PreparedQuery updateQuery() {
	
	if (null!=updateQuery || building) {
		return updateQuery;		
	} else {
		building = true;
		pm.pool().getConnection(h -> {
			
			if (h.succeeded()) {
				SqlConnection connection = h.result();
				
				connection.prepare("UPDATE world SET randomnumber=$1 WHERE id=$2", ph -> {
					if (ph.succeeded()) {							
						updateQuery = ph.result();	
						building = false;
						if (selectQuery == null) {
							selectableQuery();
						}
					} 
				});
				
				connection.close();
			} 
			
			
		});
		return null;
	}
}
 
Example #5
Source File: ThreadLocalPool.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public PreparedQuery<RowSet<Row>> preparedQuery(String sql) {
    return pool().preparedQuery(sql);
}
 
Example #6
Source File: TemplateBuilderTest.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public PreparedQuery<RowSet<Row>> preparedQuery(String sql) {
  throw new UnsupportedOperationException();
}
 
Example #7
Source File: SqlClientBase.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public PreparedQuery<RowSet<Row>> preparedQuery(String sql) {
  QueryExecutor<RowSet<Row>, RowSetImpl<Row>, RowSet<Row>> builder = new QueryExecutor<>(tracer, metrics, RowSetImpl.FACTORY, RowSetImpl.COLLECTOR);
  return new PreparedQueryImpl<>(autoCommit(), false, sql, builder);
}
 
Example #8
Source File: SqlClientBase.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public <U> PreparedQuery<SqlResult<U>> collecting(Collector<Row, ?, U> collector) {
  return (PreparedQuery<SqlResult<U>>) super.collecting(collector);
}
 
Example #9
Source File: SqlClientBase.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public <U> PreparedQuery<RowSet<U>> mapping(Function<Row, U> mapper) {
  return (PreparedQuery<RowSet<U>>) super.mapping(mapper);
}
 
Example #10
Source File: PreparedStatementImpl.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public PreparedQuery<RowSet<Row>> query() {
  QueryExecutor<RowSet<Row>, RowSetImpl<Row>, RowSet<Row>> builder = new QueryExecutor<>(tracer, metrics, RowSetImpl.FACTORY, RowSetImpl.COLLECTOR);
  return new PreparedStatementQuery<>(builder);
}
 
Example #11
Source File: PreparedStatementImpl.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public <U> PreparedQuery<SqlResult<U>> collecting(Collector<Row, ?, U> collector) {
  return (PreparedQuery<SqlResult<U>>) super.collecting(collector);
}
 
Example #12
Source File: PreparedStatementImpl.java    From vertx-sql-client with Apache License 2.0 4 votes vote down vote up
@Override
public <U> PreparedQuery<RowSet<U>> mapping(Function<Row, U> mapper) {
  return (PreparedQuery<RowSet<U>>) super.mapping(mapper);
}
 
Example #13
Source File: PostgresQueryTest.java    From okapi with Apache License 2.0 4 votes vote down vote up
@Override
public SqlConnection prepare(String string, Handler<AsyncResult<PreparedQuery>> hndlr) {
  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
Example #14
Source File: PostgresQueryTest.java    From okapi with Apache License 2.0 4 votes vote down vote up
@Override
public Future<PreparedQuery> prepare(String string) {
  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
 
Example #15
Source File: PostgresClientTest.java    From raml-module-builder with Apache License 2.0 4 votes vote down vote up
@Override
public PreparedQuery<RowSet<Row>> preparedQuery(String s) {
  return null;
}