com.github.wyukawa.elasticsearch.unofficial.jdbc.driver.ElasticsearchConnection Maven / Gradle / Ivy
The newest version!
package com.github.wyukawa.elasticsearch.unofficial.jdbc.driver;
import java.sql.*;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
public class ElasticsearchConnection implements Connection {
private final String httpUrl;
private boolean closed;
public ElasticsearchConnection(String url, Properties info) {
// https://www.elastic.co/guide/en/elasticsearch/reference/6.3/sql-rest.html
// https://www.elastic.co/guide/en/elasticsearch/reference/6.3/sql-jdbc.html
//
// jdbc:es:localhost:9200
// → localhost:9200/_xpack/sql?format=txt
this.httpUrl = "http://" + url.substring(ElasticsearchDriver.DRIVER_URL_START.length()) + "/_xpack/sql?format=json";
}
@Override
public Statement createStatement() throws SQLException {
throw new SQLFeatureNotSupportedException("createStatement");
}
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException {
return new ElasticsearchPreparedStatement(this.httpUrl, sql);
}
@Override
public CallableStatement prepareCall(String sql) throws SQLException {
throw new SQLFeatureNotSupportedException("prepareCall");
}
@Override
public String nativeSQL(String sql) throws SQLException {
throw new SQLFeatureNotSupportedException("nativeSQL");
}
@Override
public boolean getAutoCommit() throws SQLException {
throw new SQLFeatureNotSupportedException("getAutoCommit");
}
@Override
public void setAutoCommit(boolean autoCommit) throws SQLException {
throw new SQLFeatureNotSupportedException("setAutoCommit");
}
@Override
public void commit() throws SQLException {
throw new SQLFeatureNotSupportedException("commit");
}
@Override
public void rollback() throws SQLException {
throw new SQLFeatureNotSupportedException("rollback");
}
@Override
public void close() throws SQLException {
this.closed = true;
}
@Override
public boolean isClosed() throws SQLException {
return closed;
}
@Override
public DatabaseMetaData getMetaData() throws SQLException {
throw new SQLFeatureNotSupportedException("getMetaData");
}
@Override
public boolean isReadOnly() throws SQLException {
throw new SQLFeatureNotSupportedException("isReadOnly");
}
@Override
public void setReadOnly(boolean readOnly) throws SQLException {
throw new SQLFeatureNotSupportedException("setReadOnly");
}
@Override
public String getCatalog() throws SQLException {
throw new SQLFeatureNotSupportedException("getCatalog");
}
@Override
public void setCatalog(String catalog) throws SQLException {
throw new SQLFeatureNotSupportedException("setCatalog");
}
@Override
public int getTransactionIsolation() throws SQLException {
throw new SQLFeatureNotSupportedException("getTransactionIsolation");
}
@Override
public void setTransactionIsolation(int level) throws SQLException {
throw new SQLFeatureNotSupportedException("setTransactionIsolation");
}
@Override
public SQLWarning getWarnings() throws SQLException {
throw new SQLFeatureNotSupportedException("getWarnings");
}
@Override
public void clearWarnings() throws SQLException {
throw new SQLFeatureNotSupportedException("clearWarnings");
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
throw new SQLFeatureNotSupportedException("createStatement");
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
throw new SQLFeatureNotSupportedException("prepareStatement");
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
throw new SQLFeatureNotSupportedException("prepareCall");
}
@Override
public Map> getTypeMap() throws SQLException {
throw new SQLFeatureNotSupportedException("getTypeMap");
}
@Override
public void setTypeMap(Map> map) throws SQLException {
throw new SQLFeatureNotSupportedException("setTypeMap");
}
@Override
public int getHoldability() throws SQLException {
throw new SQLFeatureNotSupportedException("getHoldability");
}
@Override
public void setHoldability(int holdability) throws SQLException {
throw new SQLFeatureNotSupportedException("setHoldability");
}
@Override
public Savepoint setSavepoint() throws SQLException {
throw new SQLFeatureNotSupportedException("setSavepoint");
}
@Override
public Savepoint setSavepoint(String name) throws SQLException {
throw new SQLFeatureNotSupportedException("setSavepoint");
}
@Override
public void rollback(Savepoint savepoint) throws SQLException {
throw new SQLFeatureNotSupportedException("rollback");
}
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
throw new SQLFeatureNotSupportedException("releaseSavepoint");
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
throw new SQLFeatureNotSupportedException("createStatement");
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
throw new SQLFeatureNotSupportedException("prepareStatement");
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
throw new SQLFeatureNotSupportedException("prepareCall");
}
@Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
throw new SQLFeatureNotSupportedException("prepareStatement");
}
@Override
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
throw new SQLFeatureNotSupportedException("prepareStatement");
}
@Override
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
throw new SQLFeatureNotSupportedException("prepareStatement");
}
@Override
public Clob createClob() throws SQLException {
throw new SQLFeatureNotSupportedException("createClob");
}
@Override
public Blob createBlob() throws SQLException {
throw new SQLFeatureNotSupportedException("createBlob");
}
@Override
public NClob createNClob() throws SQLException {
throw new SQLFeatureNotSupportedException("createNClob");
}
@Override
public SQLXML createSQLXML() throws SQLException {
throw new SQLFeatureNotSupportedException("createSQLXML");
}
@Override
public boolean isValid(int timeout) throws SQLException {
throw new SQLFeatureNotSupportedException("isValid");
}
@Override
public void setClientInfo(String name, String value) throws SQLClientInfoException {
throw new SQLClientInfoException();
}
@Override
public String getClientInfo(String name) throws SQLException {
throw new SQLFeatureNotSupportedException("getClientInfo");
}
@Override
public Properties getClientInfo() throws SQLException {
throw new SQLFeatureNotSupportedException("getClientInfo");
}
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
throw new SQLClientInfoException();
}
@Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
throw new SQLFeatureNotSupportedException("createArrayOf");
}
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
throw new SQLFeatureNotSupportedException("createStruct");
}
@Override
public String getSchema() throws SQLException {
throw new SQLFeatureNotSupportedException("getSchema");
}
@Override
public void setSchema(String schema) throws SQLException {
throw new SQLFeatureNotSupportedException("setSchema");
}
@Override
public void abort(Executor executor) throws SQLException {
throw new SQLFeatureNotSupportedException("abort");
}
@Override
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
throw new SQLFeatureNotSupportedException("setNetworkTimeout");
}
@Override
public int getNetworkTimeout() throws SQLException {
throw new SQLFeatureNotSupportedException("getNetworkTimeout");
}
@Override
public T unwrap(Class iface) throws SQLException {
throw new SQLFeatureNotSupportedException("unwrap");
}
@Override
public boolean isWrapperFor(Class> iface) throws SQLException {
throw new SQLFeatureNotSupportedException("isWrapperFor");
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy