Java Code Examples for io.vertx.sqlclient.PreparedQuery

The following examples show how to use io.vertx.sqlclient.PreparedQuery. 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
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 Project: vertx-sql-client   Source File: SqlTemplateImpl.java    License: 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
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
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 Project: quarkus   Source File: ThreadLocalPool.java    License: 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 Project: vertx-sql-client   Source File: TemplateBuilderTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public PreparedQuery<RowSet<Row>> preparedQuery(String sql) {
  throw new UnsupportedOperationException();
}
 
Example 7
Source Project: vertx-sql-client   Source File: SqlClientBase.java    License: 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 Project: vertx-sql-client   Source File: SqlClientBase.java    License: 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 Project: vertx-sql-client   Source File: SqlClientBase.java    License: 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 Project: vertx-sql-client   Source File: PreparedStatementImpl.java    License: 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 Project: vertx-sql-client   Source File: PreparedStatementImpl.java    License: 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 Project: vertx-sql-client   Source File: PreparedStatementImpl.java    License: 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 Project: okapi   Source File: PostgresQueryTest.java    License: 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 Project: okapi   Source File: PostgresQueryTest.java    License: 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 Project: raml-module-builder   Source File: PostgresClientTest.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public PreparedQuery<RowSet<Row>> preparedQuery(String s) {
  return null;
}