com.aerospike.jdbc.AerospikeStatement Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aerospike-jdbc Show documentation
Show all versions of aerospike-jdbc Show documentation
A JDBC driver for the Aerospike database
package com.aerospike.jdbc;
import com.aerospike.client.IAerospikeClient;
import com.aerospike.jdbc.model.AerospikeQuery;
import com.aerospike.jdbc.model.Pair;
import com.aerospike.jdbc.model.QueryType;
import com.aerospike.jdbc.query.QueryPerformer;
import com.aerospike.jdbc.sql.SimpleWrapper;
import com.aerospike.jdbc.util.AuxStatementParser;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.Statement;
import java.util.List;
import java.util.logging.Logger;
import static java.lang.String.format;
import static java.sql.ResultSet.CLOSE_CURSORS_AT_COMMIT;
import static java.sql.ResultSet.CONCUR_READ_ONLY;
import static java.sql.ResultSet.FETCH_FORWARD;
import static java.sql.ResultSet.TYPE_FORWARD_ONLY;
public class AerospikeStatement implements Statement, SimpleWrapper {
protected static final String BATCH_NOT_SUPPORTED_MESSAGE = "Batch update is not supported";
private static final Logger logger = Logger.getLogger(AerospikeStatement.class.getName());
private static final String AUTO_GENERATED_KEYS_NOT_SUPPORTED_MESSAGE = "Auto-generated keys are not supported";
protected final IAerospikeClient client;
protected final AerospikeConnection connection;
protected String catalog;
protected ResultSet resultSet;
protected int updateCount;
private int maxRows = Integer.MAX_VALUE;
private int queryTimeout;
public AerospikeStatement(IAerospikeClient client, AerospikeConnection connection) {
this.client = client;
this.connection = connection;
this.catalog = connection.getCatalog();
}
@Override
public ResultSet executeQuery(String sql) throws SQLException {
logger.info(() -> "executeQuery: " + sql);
AerospikeQuery query = parseQuery(sql, null);
runQuery(query);
return resultSet;
}
protected void runQuery(AerospikeQuery query) {
Pair result = QueryPerformer.executeQuery(client, this, query);
resultSet = result.getLeft();
updateCount = result.getRight();
}
protected AerospikeQuery parseQuery(String sql, List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy