
com.julienviet.pgclient.impl.PostgresConnectionImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vertx-pg-client Show documentation
Show all versions of vertx-pg-client Show documentation
A Postgres client for Eclipse Vert.x
The newest version!
/*
* Copyright (C) 2017 Julien Viet
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.julienviet.pgclient.impl;
import com.julienviet.pgclient.PgConnection;
import com.julienviet.pgclient.PgPreparedStatement;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.ext.sql.ResultSet;
import io.vertx.ext.sql.UpdateResult;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author Julien Viet
*/
class PostgresConnectionImpl implements PgConnection {
private DbConnection dbConnection;
private final Map psCache;
public PostgresConnectionImpl(DbConnection dbConnection, boolean cachePreparedStatements) {
this.dbConnection = dbConnection;
this.psCache = cachePreparedStatements ? new ConcurrentHashMap<>() : null;
}
@Override
public PgConnection execute(String sql, Handler> handler) {
dbConnection.schedule(new QueryCommand(sql, new ResultSetBuilder(handler)));
return this;
}
@Override
public PgConnection update(String sql, Handler> handler) {
dbConnection.schedule(new UpdateCommand(sql, handler));
return this;
}
@Override
public PgConnection query(String sql, Handler> handler) {
dbConnection.schedule(new QueryCommand(sql, new ResultSetBuilder(handler)));
return this;
}
@Override
public PgConnection prepareAndQuery(String sql, List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy