spuerx 9 年之前
父節點
當前提交
715ac613e9
共有 23 個文件被更改,包括 3030 次插入1951 次删除
  1. 1 3
      src/main/java/org/elasticsearch/util/ElasticMockClient.java
  2. 1 1
      src/main/java/org/elasticsearch/dsl/bean/ElasticSqlParseResult.java
  3. 139 0
      src/main/java/org/elasticsearch/jdbc/AbstractConnection.java
  4. 3 2
      src/main/java/org/elasticsearch/jdbc/AbstractDataSource.java
  5. 4 67
      src/main/java/org/elasticsearch/jdbc/AbstractDriverBasedDataSource.java
  6. 150 0
      src/main/java/org/elasticsearch/jdbc/AbstractFeatureNotSupportedConnection.java
  7. 975 0
      src/main/java/org/elasticsearch/jdbc/AbstractFeatureNotSupportedResultSet.java
  8. 99 0
      src/main/java/org/elasticsearch/jdbc/AbstractFeatureNotSupportedStatement.java
  9. 98 0
      src/main/java/org/elasticsearch/jdbc/AbstractResultSet.java
  10. 124 0
      src/main/java/org/elasticsearch/jdbc/AbstractStatement.java
  11. 0 9
      src/main/java/org/elasticsearch/jdbc/ConnectionProxy.java
  12. 2 36
      src/main/java/org/elasticsearch/jdbc/DriverManagerDataSource.java
  13. 18 1505
      src/main/java/org/elasticsearch/jdbc/ElasticConnection.java
  14. 892 0
      src/main/java/org/elasticsearch/jdbc/ElasticDatabaseMetaData.java
  15. 11 5
      src/main/java/org/elasticsearch/jdbc/ElasticDriver.java
  16. 60 0
      src/main/java/org/elasticsearch/jdbc/ElasticResultSet.java
  17. 132 0
      src/main/java/org/elasticsearch/jdbc/ElasticResultSetMetaData.java
  18. 195 0
      src/main/java/org/elasticsearch/jdbc/ElasticSingleConnectionDataSource.java
  19. 47 0
      src/main/java/org/elasticsearch/jdbc/ElasticStatement.java
  20. 0 319
      src/main/java/org/elasticsearch/jdbc/SingleConnectionDataSource.java
  21. 44 0
      src/main/java/org/elasticsearch/jdbc/TransportClientFactory.java
  22. 34 3
      src/test/java/org/elasticsearch/jdbc/ElasticDriverTest.java
  23. 1 1
      src/test/java/org/elasticsearch/query/SqlParserWhereConditionTest.java

+ 1 - 3
src/main/java/org/elasticsearch/util/ElasticMockClient.java

@@ -1,4 +1,4 @@
-package org.elasticsearch.util;
+package org.elasticsearch.client;
 
 import org.elasticsearch.action.*;
 import org.elasticsearch.action.bulk.BulkRequest;
@@ -41,8 +41,6 @@ import org.elasticsearch.action.termvectors.*;
 import org.elasticsearch.action.update.UpdateRequest;
 import org.elasticsearch.action.update.UpdateRequestBuilder;
 import org.elasticsearch.action.update.UpdateResponse;
-import org.elasticsearch.client.AdminClient;
-import org.elasticsearch.client.Client;
 import org.elasticsearch.client.support.Headers;
 import org.elasticsearch.common.settings.Settings;
 import org.elasticsearch.threadpool.ThreadPool;

+ 1 - 1
src/main/java/org/elasticsearch/dsl/bean/ElasticSqlParseResult.java

@@ -10,7 +10,7 @@ import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
 import org.elasticsearch.search.aggregations.AggregationBuilder;
 import org.elasticsearch.search.sort.SortBuilder;
-import org.elasticsearch.util.ElasticMockClient;
+import org.elasticsearch.client.ElasticMockClient;
 
 import java.util.List;
 

+ 139 - 0
src/main/java/org/elasticsearch/jdbc/AbstractConnection.java

@@ -0,0 +1,139 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.*;
+import java.util.Properties;
+
+public abstract class AbstractConnection extends AbstractFeatureNotSupportedConnection {
+    private boolean closed = false;
+    private int transactionIsolation;
+
+    protected String url;
+    protected Properties info;
+
+    public AbstractConnection(String url, Properties info) {
+        this.url = url;
+        this.info = info;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public final <T> T unwrap(final Class<T> iface) throws SQLException {
+        if (isWrapperFor(iface)) {
+            return (T) this;
+        }
+        throw new SQLException(String.format("[%s] cannot be unwrapped as [%s]", getClass().getName(), iface.getName()));
+    }
+
+    @Override
+    public final boolean isWrapperFor(final Class<?> iface) throws SQLException {
+        return iface.isInstance(this);
+    }
+
+    @Override
+    public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
+        return createStatement();
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
+        return prepareStatement(sql);
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
+        return prepareStatement(sql);
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
+        return prepareStatement(sql);
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
+        return prepareStatement(sql);
+    }
+
+    @Override
+    public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        return prepareStatement(sql);
+    }
+
+    @Override
+    public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
+        return createStatement();
+    }
+
+
+    @Override
+    public boolean getAutoCommit() throws SQLException {
+        return true;
+    }
+
+
+    @Override
+    public void setTransactionIsolation(int level) throws SQLException {
+        this.transactionIsolation = level;
+    }
+
+    @Override
+    public int getTransactionIsolation() throws SQLException {
+        return transactionIsolation;
+    }
+
+    @Override
+    public boolean isReadOnly() throws SQLException {
+        return true;
+    }
+
+    @Override
+    public void close() throws SQLException {
+        closed = true;
+    }
+
+    @Override
+    public boolean isClosed() throws SQLException {
+        return closed;
+    }
+
+    @Override
+    public void setReadOnly(boolean readOnly) throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public void commit() throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public void rollback() throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public void setAutoCommit(boolean autoCommit) throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public SQLWarning getWarnings() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public void clearWarnings() throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public final int getHoldability() throws SQLException {
+        return ResultSet.HOLD_CURSORS_OVER_COMMIT;
+    }
+
+    @Override
+    public final void setHoldability(final int holdability) throws SQLException {
+        // ignore
+    }
+
+}

+ 3 - 2
src/main/java/org/elasticsearch/jdbc/AbstractDataSource.java

@@ -4,6 +4,7 @@ package org.elasticsearch.jdbc;
 import javax.sql.DataSource;
 import java.io.PrintWriter;
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 import java.util.logging.Logger;
 
 
@@ -20,7 +21,7 @@ public abstract class AbstractDataSource implements DataSource {
      * Setting a login timeout is not supported.
      */
     public void setLoginTimeout(int timeout) throws SQLException {
-        throw new UnsupportedOperationException("setLoginTimeout");
+        throw new SQLFeatureNotSupportedException("setLoginTimeout");
     }
 
     /**
@@ -34,7 +35,7 @@ public abstract class AbstractDataSource implements DataSource {
      * LogWriter methods are not supported.
      */
     public void setLogWriter(PrintWriter pw) throws SQLException {
-        throw new UnsupportedOperationException("setLogWriter");
+        throw new SQLFeatureNotSupportedException("setLogWriter");
     }
 
 

+ 4 - 67
src/main/java/org/elasticsearch/jdbc/AbstractDriverBasedDataSource.java

@@ -14,104 +14,50 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
 
     private Properties connectionProperties;
 
-
     public void setUrl(String url) {
         this.url = url.trim();
     }
 
-    /**
-     * Return the JDBC URL to use for connecting through the Driver.
-     */
     public String getUrl() {
         return this.url;
     }
 
-    /**
-     * Set the JDBC username to use for connecting through the Driver.
-     *
-     * @see java.sql.Driver#connect(String, java.util.Properties)
-     */
+
     public void setUsername(String username) {
         this.username = username;
     }
 
-    /**
-     * Return the JDBC username to use for connecting through the Driver.
-     */
+
     public String getUsername() {
         return this.username;
     }
 
-    /**
-     * Set the JDBC password to use for connecting through the Driver.
-     *
-     * @see java.sql.Driver#connect(String, java.util.Properties)
-     */
+
     public void setPassword(String password) {
         this.password = password;
     }
 
-    /**
-     * Return the JDBC password to use for connecting through the Driver.
-     */
     public String getPassword() {
         return this.password;
     }
 
-    /**
-     * Specify arbitrary connection properties as key/value pairs,
-     * to be passed to the Driver.
-     * <p>Can also contain "user" and "password" properties. However,
-     * any "username" and "password" bean properties specified on this
-     * DataSource will override the corresponding connection properties.
-     *
-     * @see java.sql.Driver#connect(String, java.util.Properties)
-     */
+
     public void setConnectionProperties(Properties connectionProperties) {
         this.connectionProperties = connectionProperties;
     }
 
-    /**
-     * Return the connection properties to be passed to the Driver, if any.
-     */
     public Properties getConnectionProperties() {
         return this.connectionProperties;
     }
 
-
-    /**
-     * This implementation delegates to {@code getConnectionFromDriver},
-     * using the default username and password of this DataSource.
-     *
-     * @see #getConnectionFromDriver(String, String)
-     * @see #setUsername
-     * @see #setPassword
-     */
     public Connection getConnection() throws SQLException {
         return getConnectionFromDriver(getUsername(), getPassword());
     }
 
-    /**
-     * This implementation delegates to {@code getConnectionFromDriver},
-     * using the given username and password.
-     *
-     * @see #getConnectionFromDriver(String, String)
-     */
     public Connection getConnection(String username, String password) throws SQLException {
         return getConnectionFromDriver(username, password);
     }
 
-
-    /**
-     * Build properties for the Driver, including the given username and password (if any),
-     * and obtain a corresponding Connection.
-     *
-     * @param username the name of the user
-     * @param password the password to use
-     * @return the obtained Connection
-     * @throws SQLException in case of failure
-     * @see java.sql.Driver#connect(String, java.util.Properties)
-     */
     protected Connection getConnectionFromDriver(String username, String password) throws SQLException {
         Properties mergedProps = new Properties();
         Properties connProps = getConnectionProperties();
@@ -127,14 +73,5 @@ public abstract class AbstractDriverBasedDataSource extends AbstractDataSource {
         return getConnectionFromDriver(mergedProps);
     }
 
-    /**
-     * Obtain a Connection using the given properties.
-     * <p>Template method to be implemented by subclasses.
-     *
-     * @param props the merged connection properties
-     * @return the obtained Connection
-     * @throws SQLException in case of failure
-     */
     protected abstract Connection getConnectionFromDriver(Properties props) throws SQLException;
-
 }

+ 150 - 0
src/main/java/org/elasticsearch/jdbc/AbstractFeatureNotSupportedConnection.java

@@ -0,0 +1,150 @@
+package org.elasticsearch.jdbc;
+
+
+import java.sql.*;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.Executor;
+
+public abstract class AbstractFeatureNotSupportedConnection implements Connection {
+
+    @Override
+    public final CallableStatement prepareCall(final String sql) throws SQLException {
+        throw new SQLFeatureNotSupportedException("prepareCall");
+    }
+
+    @Override
+    public final CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency) throws SQLException {
+        throw new SQLFeatureNotSupportedException("prepareCall");
+    }
+
+    @Override
+    public final CallableStatement prepareCall(final String sql, final int resultSetType, final int resultSetConcurrency, final int resultSetHoldability) throws SQLException {
+        throw new SQLFeatureNotSupportedException("prepareCall");
+    }
+
+    @Override
+    public final String nativeSQL(final String sql) throws SQLException {
+        throw new SQLFeatureNotSupportedException("nativeSQL");
+    }
+
+    @Override
+    public final Savepoint setSavepoint() throws SQLException {
+        throw new SQLFeatureNotSupportedException("setSavepoint");
+    }
+
+    @Override
+    public final Savepoint setSavepoint(final String name) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setSavepoint name");
+    }
+
+    @Override
+    public final void releaseSavepoint(final Savepoint savepoint) throws SQLException {
+        throw new SQLFeatureNotSupportedException("releaseSavepoint");
+    }
+
+    @Override
+    public final void rollback(final Savepoint savepoint) throws SQLException {
+        throw new SQLFeatureNotSupportedException("rollback savepoint");
+    }
+
+    @Override
+    public final void abort(final Executor executor) throws SQLException {
+        throw new SQLFeatureNotSupportedException("abort");
+    }
+
+    @Override
+    public final String getCatalog() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getCatalog");
+    }
+
+    @Override
+    public final void setCatalog(final String catalog) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setCatalog");
+    }
+
+    @Override
+    public final String getSchema() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getSchema");
+    }
+
+    @Override
+    public final void setSchema(final String schema) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setSchema");
+    }
+
+    @Override
+    public final Map<String, Class<?>> getTypeMap() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTypeMap");
+    }
+
+    @Override
+    public final void setTypeMap(final Map<String, Class<?>> map) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setTypeMap");
+    }
+
+    @Override
+    public final int getNetworkTimeout() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNetworkTimeout");
+    }
+
+    @Override
+    public final void setNetworkTimeout(final Executor executor, final int milliseconds) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setNetworkTimeout");
+    }
+
+    @Override
+    public final Clob createClob() throws SQLException {
+        throw new SQLFeatureNotSupportedException("createClob");
+    }
+
+    @Override
+    public final Blob createBlob() throws SQLException {
+        throw new SQLFeatureNotSupportedException("createBlob");
+    }
+
+    @Override
+    public final NClob createNClob() throws SQLException {
+        throw new SQLFeatureNotSupportedException("createNClob");
+    }
+
+    @Override
+    public final SQLXML createSQLXML() throws SQLException {
+        throw new SQLFeatureNotSupportedException("createSQLXML");
+    }
+
+    @Override
+    public final Array createArrayOf(final String typeName, final Object[] elements) throws SQLException {
+        throw new SQLFeatureNotSupportedException("createArrayOf");
+    }
+
+    @Override
+    public final Struct createStruct(final String typeName, final Object[] attributes) throws SQLException {
+        throw new SQLFeatureNotSupportedException("createStruct");
+    }
+
+    @Override
+    public final boolean isValid(final int timeout) throws SQLException {
+        throw new SQLFeatureNotSupportedException("isValid");
+    }
+
+    @Override
+    public final Properties getClientInfo() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getClientInfo");
+    }
+
+    @Override
+    public final String getClientInfo(final String name) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getClientInfo name");
+    }
+
+    @Override
+    public final void setClientInfo(final String name, final String value) throws SQLClientInfoException {
+        throw new UnsupportedOperationException("setClientInfo name value");
+    }
+
+    @Override
+    public final void setClientInfo(final Properties properties) throws SQLClientInfoException {
+        throw new UnsupportedOperationException("setClientInfo properties");
+    }
+}

+ 975 - 0
src/main/java/org/elasticsearch/jdbc/AbstractFeatureNotSupportedResultSet.java

@@ -0,0 +1,975 @@
+package org.elasticsearch.jdbc;
+
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.*;
+import java.util.Calendar;
+import java.util.Map;
+
+public abstract class AbstractFeatureNotSupportedResultSet implements ResultSet {
+    @Override
+    public void cancelRowUpdates() throws SQLException {
+        throw new SQLFeatureNotSupportedException("cancelRowUpdates");
+    }
+
+    @Override
+    public void deleteRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("deleteRow");
+    }
+
+    @Override
+    public void insertRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("insertRow");
+    }
+
+    @Override
+    public void moveToCurrentRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("moveToCurrentRow");
+    }
+
+    @Override
+    public void moveToInsertRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("moveToInsertRow");
+    }
+
+    @Override
+    public void refreshRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("refreshRow");
+    }
+
+    @Override
+    public void updateRow() throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateRow");
+    }
+
+
+    @Override
+    public boolean first() throws SQLException {
+        throw new SQLFeatureNotSupportedException("first");
+    }
+
+    @Override
+    public boolean isAfterLast() throws SQLException {
+        throw new SQLFeatureNotSupportedException("isAfterLast");
+    }
+
+    @Override
+    public boolean isBeforeFirst() throws SQLException {
+        throw new SQLFeatureNotSupportedException("isBeforeFirst");
+    }
+
+    @Override
+    public boolean isFirst() throws SQLException {
+        throw new SQLFeatureNotSupportedException("isFirst");
+    }
+
+
+    @Override
+    public boolean isLast() throws SQLException {
+        throw new SQLFeatureNotSupportedException("isLast");
+    }
+
+    @Override
+    public boolean last() throws SQLException {
+        throw new SQLFeatureNotSupportedException("last");
+    }
+
+    @Override
+    public boolean previous() throws SQLException {
+        throw new SQLFeatureNotSupportedException("previous");
+    }
+
+    @Override
+    public boolean rowDeleted() throws SQLException {
+        throw new SQLFeatureNotSupportedException("rowDeleted");
+    }
+
+    @Override
+    public boolean rowInserted() throws SQLException {
+        throw new SQLFeatureNotSupportedException("rowInserted");
+    }
+
+    @Override
+    public boolean rowUpdated() throws SQLException {
+        throw new SQLFeatureNotSupportedException("rowUpdated");
+    }
+
+    @Override
+    public void setFetchDirection(int direction) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setFetchDirection");
+    }
+
+    @Override
+    public void setFetchSize(int rows) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setFetchSize");
+    }
+
+    @Override
+    public boolean absolute(int row) throws SQLException {
+        throw new SQLFeatureNotSupportedException("absolute");
+    }
+
+
+    @Override
+    public boolean relative(int offset) throws SQLException {
+        throw new SQLFeatureNotSupportedException("relative");
+    }
+
+    @Override
+    public String getCursorName() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getCursorName");
+    }
+
+    @Override
+    public void updateArray(int columnIndex, Array x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateArray");
+    }
+
+    @Override
+    public void updateArray(String columnLabel, Array x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateArray");
+    }
+
+
+    @Override
+    public void updateAsciiStream(int columnIndex, InputStream x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateAsciiStream");
+    }
+
+
+    @Override
+    public void updateAsciiStream(String columnLabel, InputStream x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateAsciiStream");
+    }
+
+
+    @Override
+    public void updateAsciiStream(int columnIndex, InputStream x, int length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateAsciiStream");
+    }
+
+
+    @Override
+    public void updateAsciiStream(String columnLabel, InputStream x, int length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateAsciiStream");
+    }
+
+
+    @Override
+    public void updateAsciiStream(int columnIndex, InputStream x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateAsciiStream");
+    }
+
+
+    @Override
+    public void updateAsciiStream(String columnLabel, InputStream x, long length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateAsciiStream");
+    }
+
+
+    @Override
+    public void updateBigDecimal(int columnIndex, BigDecimal x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBigDecimal");
+    }
+
+
+    @Override
+    public void updateBigDecimal(String columnLabel, BigDecimal x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBigDecimal");
+    }
+
+
+    @Override
+    public void updateBinaryStream(int columnIndex, InputStream x)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBinaryStream");
+    }
+
+
+    @Override
+    public void updateBinaryStream(String columnLabel, InputStream x)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBinaryStream");
+    }
+
+
+    @Override
+    public void updateBinaryStream(int columnIndex, InputStream x, int length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBinaryStream");
+    }
+
+
+    @Override
+    public void updateBinaryStream(String columnLabel, InputStream x, int length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBinaryStream");
+    }
+
+
+    @Override
+    public void updateBinaryStream(int columnIndex, InputStream x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBinaryStream");
+    }
+
+
+    @Override
+    public void updateBinaryStream(String columnLabel, InputStream x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBinaryStream");
+    }
+
+
+    @Override
+    public void updateBlob(int columnIndex, Blob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBlob");
+    }
+
+
+    @Override
+    public void updateBlob(String columnLabel, Blob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBlob");
+    }
+
+
+    @Override
+    public void updateBlob(int columnIndex, InputStream x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBlob");
+    }
+
+
+    @Override
+    public void updateBlob(String columnLabel, InputStream x)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBlob");
+    }
+
+
+    @Override
+    public void updateBlob(int columnIndex, InputStream x, long length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBlob");
+    }
+
+
+    @Override
+    public void updateBlob(String columnLabel, InputStream x, long length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBlob");
+    }
+
+
+    @Override
+    public void updateBoolean(int columnIndex, boolean x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBoolean");
+    }
+
+
+    @Override
+    public void updateBoolean(String columnLabel, boolean x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBoolean");
+    }
+
+
+    @Override
+    public void updateByte(int columnIndex, byte x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBytes");
+    }
+
+
+    @Override
+    public void updateByte(String columnLabel, byte x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBytes");
+    }
+
+
+    @Override
+    public void updateBytes(int columnIndex, byte[] x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBytes");
+    }
+
+
+    @Override
+    public void updateBytes(String columnLabel, byte[] x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateBytes");
+    }
+
+
+    @Override
+    public void updateCharacterStream(int columnIndex, Reader x)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateCharacterStream");
+    }
+
+
+    @Override
+    public void updateCharacterStream(String columnLabel, Reader x)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateCharacterStream");
+    }
+
+
+    @Override
+    public void updateCharacterStream(int columnIndex, Reader x, int length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateCharacterStream");
+    }
+
+
+    @Override
+    public void updateCharacterStream(String columnLabel, Reader x, int length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateCharacterStream");
+    }
+
+
+    @Override
+    public void updateCharacterStream(int columnIndex, Reader x, long length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateCharacterStream");
+    }
+
+
+    @Override
+    public void updateCharacterStream(String columnLabel, Reader x, long length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateCharacterStream");
+    }
+
+
+    @Override
+    public void updateClob(int columnIndex, Clob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateClob");
+    }
+
+
+    @Override
+    public void updateClob(String columnLabel, Clob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateClob");
+    }
+
+
+    @Override
+    public void updateClob(int columnIndex, Reader x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateClob");
+    }
+
+
+    @Override
+    public void updateClob(String columnLabel, Reader x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateClob");
+    }
+
+
+    @Override
+    public void updateClob(int columnIndex, Reader x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateClob");
+    }
+
+
+    @Override
+    public void updateClob(String columnLabel, Reader x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateClob");
+    }
+
+
+    @Override
+    public void updateDate(int columnIndex, Date x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateDate");
+    }
+
+
+    @Override
+    public void updateDate(String columnLabel, Date x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateDate");
+    }
+
+
+    @Override
+    public void updateDouble(int columnIndex, double x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateDouble");
+    }
+
+
+    @Override
+    public void updateDouble(String columnLabel, double x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateDouble");
+    }
+
+
+    @Override
+    public void updateFloat(int columnIndex, float x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateFloat");
+    }
+
+
+    @Override
+    public void updateFloat(String columnLabel, float x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateFloat");
+    }
+
+
+    @Override
+    public void updateInt(int columnIndex, int x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateInt");
+    }
+
+
+    @Override
+    public void updateInt(String columnLabel, int x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateInt");
+    }
+
+
+    @Override
+    public void updateLong(int columnIndex, long x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateLong");
+    }
+
+
+    @Override
+    public void updateLong(String columnLabel, long x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateLong");
+    }
+
+
+    @Override
+    public void updateNCharacterStream(int columnIndex, Reader x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNCharacterStream");
+    }
+
+
+    @Override
+    public void updateNCharacterStream(String columnLabel, Reader x)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNCharacterStream");
+    }
+
+
+    @Override
+    public void updateNCharacterStream(int columnIndex, Reader x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNCharacterStream");
+    }
+
+
+    @Override
+    public void updateNCharacterStream(String columnLabel, Reader x, long length) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNCharacterStream");
+    }
+
+
+    @Override
+    public void updateNClob(int columnIndex, NClob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNClob");
+    }
+
+
+    @Override
+    public void updateNClob(String columnLabel, NClob x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNClob");
+    }
+
+
+    @Override
+    public void updateNClob(int columnIndex, Reader x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNClob");
+    }
+
+
+    @Override
+    public void updateNClob(String columnLabel, Reader x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNClob");
+    }
+
+
+    @Override
+    public void updateNClob(int columnIndex, Reader x, long length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNClob");
+    }
+
+
+    @Override
+    public void updateNClob(String columnLabel, Reader x, long length)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNClob");
+    }
+
+
+    @Override
+    public void updateNString(int columnIndex, String x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNString");
+    }
+
+
+    @Override
+    public void updateNString(String columnLabel, String x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNString");
+    }
+
+
+    @Override
+    public void updateNull(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNull");
+    }
+
+
+    @Override
+    public void updateNull(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateNull");
+    }
+
+
+    @Override
+    public void updateObject(int columnIndex, Object x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateObject");
+    }
+
+
+    @Override
+    public void updateObject(String columnLabel, Object x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateObject");
+    }
+
+
+    @Override
+    public void updateObject(int columnIndex, Object x, int scale) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateObject");
+    }
+
+
+    @Override
+    public void updateObject(String columnLabel, Object x, int scale) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateObject");
+    }
+
+
+    @Override
+    public void updateRef(int columnIndex, Ref x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateRef");
+    }
+
+
+    @Override
+    public void updateRef(String columnLabel, Ref x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateRef");
+    }
+
+
+    @Override
+    public void updateRowId(int columnIndex, RowId x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateRowId");
+    }
+
+
+    @Override
+    public void updateRowId(String columnLabel, RowId x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateRowId");
+    }
+
+
+    @Override
+    public void updateShort(int columnIndex, short x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateShort");
+    }
+
+
+    @Override
+    public void updateShort(String columnLabel, short x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateShort");
+    }
+
+
+    @Override
+    public void updateSQLXML(int columnIndex, SQLXML x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateSQLXML");
+    }
+
+
+    @Override
+    public void updateSQLXML(String columnLabel, SQLXML x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateSQLXML");
+    }
+
+
+    @Override
+    public void updateString(int columnIndex, String x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateString");
+    }
+
+
+    @Override
+    public void updateString(String columnLabel, String x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateString");
+    }
+
+
+    @Override
+    public void updateTime(int columnIndex, Time x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateTime");
+    }
+
+
+    @Override
+    public void updateTime(String columnLabel, Time x) throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateTime");
+    }
+
+
+    @Override
+    public void updateTimestamp(int columnIndex, Timestamp x)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateTimestamp");
+    }
+
+
+    @Override
+    public void updateTimestamp(String columnLabel, Timestamp x)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("updateTimestamp");
+    }
+
+
+    @Override
+    public Timestamp getTimestamp(int columnIndex, Calendar cal)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTimestamp");
+    }
+
+
+    @Override
+    public Timestamp getTimestamp(String columnLabel, Calendar cal)
+            throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTimestamp");
+    }
+
+    @Override
+    public InputStream getUnicodeStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getUnicodeStream");
+    }
+
+
+    @Override
+    public InputStream getUnicodeStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getUnicodeStream");
+    }
+
+
+    @Override
+    public URL getURL(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getURL");
+    }
+
+
+    @Override
+    public URL getURL(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getURL");
+    }
+
+    @Override
+    public Time getTime(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTime");
+    }
+
+    @Override
+    public Time getTime(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTime");
+    }
+
+
+    @Override
+    public Time getTime(int columnIndex, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTime");
+    }
+
+
+    @Override
+    public Time getTime(String columnLabel, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTime");
+    }
+
+    @Override
+    public Object getObject(int columnIndex, Map<String, Class<?>> map) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getObject");
+    }
+
+    @Override
+    public Object getObject(String columnLabel, Map<String, Class<?>> map) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getObject");
+    }
+
+
+    @Override
+    public Ref getRef(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getRef");
+    }
+
+    @Override
+    public Ref getRef(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getRef");
+    }
+
+    @Override
+    public RowId getRowId(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getRowId");
+    }
+
+
+    @Override
+    public RowId getRowId(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getRowId");
+    }
+
+
+    @Override
+    public short getShort(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getShort");
+    }
+
+    @Override
+    public short getShort(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getShort");
+    }
+
+
+    @Override
+    public SQLXML getSQLXML(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getSQLXML");
+    }
+
+    @Override
+    public SQLXML getSQLXML(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getSQLXML");
+    }
+
+    @Override
+    public Clob getClob(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getClob");
+    }
+
+
+    @Override
+    public Clob getClob(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getClob");
+    }
+
+
+    @Override
+    public Date getDate(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getDate");
+    }
+
+
+    @Override
+    public Date getDate(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getDate");
+    }
+
+    @Override
+    public Date getDate(int columnIndex, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getDate");
+    }
+
+    @Override
+    public Date getDate(String columnLabel, Calendar cal) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getDate");
+    }
+
+    @Override
+    public double getDouble(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getDouble");
+    }
+
+    @Override
+    public double getDouble(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getDouble");
+    }
+
+    @Override
+    public float getFloat(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getFloat");
+    }
+
+    @Override
+    public float getFloat(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getFloat");
+    }
+
+    @Override
+    public int getInt(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getInt");
+    }
+
+    @Override
+    public int getInt(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getInt");
+    }
+
+    @Override
+    public long getLong(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getLong");
+    }
+
+    @Override
+    public long getLong(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getLong");
+    }
+
+
+    @Override
+    public Reader getNCharacterStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNCharacterStream");
+    }
+
+    @Override
+    public Reader getNCharacterStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNCharacterStream");
+    }
+
+    @Override
+    public NClob getNClob(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNClob");
+    }
+
+
+    @Override
+    public NClob getNClob(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNClob");
+    }
+
+    @Override
+    public Array getArray(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getArray");
+    }
+
+    @Override
+    public Array getArray(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getArray");
+    }
+
+    @Override
+    public InputStream getAsciiStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getAsciiStream");
+    }
+
+    @Override
+    public InputStream getAsciiStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getAsciiStream");
+    }
+
+
+    @Override
+    public BigDecimal getBigDecimal(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBigDecimal");
+    }
+
+
+    @Override
+    public BigDecimal getBigDecimal(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBigDecimal");
+    }
+
+    @Override
+    public BigDecimal getBigDecimal(int columnIndex, int scale) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBigDecimal");
+    }
+
+    @Override
+    public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBigDecimal");
+    }
+
+    @Override
+    public InputStream getBinaryStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBinaryStream");
+    }
+
+    @Override
+    public InputStream getBinaryStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBinaryStream");
+    }
+
+    @Override
+    public Blob getBlob(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBlob");
+    }
+
+    @Override
+    public Blob getBlob(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBlob");
+    }
+
+
+    @Override
+    public boolean getBoolean(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBoolean");
+    }
+
+    @Override
+    public boolean getBoolean(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBoolean");
+    }
+
+    @Override
+    public byte getByte(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getByte");
+    }
+
+    @Override
+    public byte[] getBytes(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBytes");
+    }
+
+    @Override
+    public Timestamp getTimestamp(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTimestamp");
+    }
+
+    @Override
+    public byte getByte(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getByte");
+    }
+
+    @Override
+    public byte[] getBytes(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getBytes");
+    }
+
+    @Override
+    public Timestamp getTimestamp(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getTimestamp");
+    }
+
+    @Override
+    public Reader getCharacterStream(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getCharacterStream");
+    }
+
+    @Override
+    public Reader getCharacterStream(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getCharacterStream");
+    }
+
+    @Override
+    public String getNString(int columnIndex) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNString");
+    }
+
+    @Override
+    public String getNString(String columnLabel) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getNString");
+    }
+
+    @Override
+    public <T> T getObject(int columnIndex, Class<T> type) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getObject");
+    }
+
+    @Override
+    public <T> T getObject(String columnLabel, Class<T> type) throws SQLException {
+        throw new SQLFeatureNotSupportedException("getObject");
+    }
+}

+ 99 - 0
src/main/java/org/elasticsearch/jdbc/AbstractFeatureNotSupportedStatement.java

@@ -0,0 +1,99 @@
+package org.elasticsearch.jdbc;
+
+
+import java.sql.*;
+
+public abstract class AbstractFeatureNotSupportedStatement implements Statement {
+
+    @Override
+    public final int getFetchDirection() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getFetchDirection");
+    }
+
+    @Override
+    public final void setFetchDirection(final int direction) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setFetchDirection");
+    }
+
+    @Override
+    public final void addBatch(final String sql) throws SQLException {
+        throw new SQLFeatureNotSupportedException("addBatch sql");
+    }
+
+    @Override
+    public void clearBatch() throws SQLException {
+        throw new SQLFeatureNotSupportedException("clearBatch");
+    }
+
+    @Override
+    public int[] executeBatch() throws SQLException {
+        throw new SQLFeatureNotSupportedException("executeBatch");
+    }
+
+    @Override
+    public final void closeOnCompletion() throws SQLException {
+        throw new SQLFeatureNotSupportedException("closeOnCompletion");
+    }
+
+    @Override
+    public final boolean isCloseOnCompletion() throws SQLException {
+        throw new SQLFeatureNotSupportedException("isCloseOnCompletion");
+    }
+
+    @Override
+    public final int executeUpdate(String sql) throws SQLException {
+        throw new SQLFeatureNotSupportedException("executeUpdate");
+    }
+
+    @Override
+    public void setCursorName(String name) throws SQLException {
+        throw new SQLFeatureNotSupportedException("setCursorName");
+    }
+
+    @Override
+    public int getUpdateCount() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getUpdateCount");
+    }
+
+    @Override
+    public boolean getMoreResults() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getMoreResults");
+    }
+
+    @Override
+    public ResultSet getGeneratedKeys() throws SQLException {
+        throw new SQLFeatureNotSupportedException("getGeneratedKeys");
+    }
+
+    @Override
+    public int executeUpdate(String sql, int autoGeneratedKeys) throws SQLException {
+        throw new SQLFeatureNotSupportedException("executeUpdate");
+    }
+
+    @Override
+    public int executeUpdate(String sql, int[] columnIndexes) throws SQLException {
+        throw new SQLFeatureNotSupportedException("executeUpdate");
+    }
+
+
+    @Override
+    public int executeUpdate(String sql, String[] columnNames) throws SQLException {
+        throw new SQLFeatureNotSupportedException("executeUpdate");
+    }
+
+    @Override
+    public boolean execute(String sql, int autoGeneratedKeys) throws SQLException {
+        throw new SQLFeatureNotSupportedException("execute");
+    }
+
+    @Override
+    public boolean execute(String sql, int[] columnIndexes) throws SQLException {
+        throw new SQLFeatureNotSupportedException("execute");
+    }
+
+    @Override
+    public boolean execute(String sql, String[] columnNames) throws SQLException {
+        throw new SQLFeatureNotSupportedException("execute");
+    }
+
+}

+ 98 - 0
src/main/java/org/elasticsearch/jdbc/AbstractResultSet.java

@@ -0,0 +1,98 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+
+public abstract class AbstractResultSet extends AbstractFeatureNotSupportedResultSet {
+
+    protected boolean isClosed = false;
+
+    protected Statement statement;
+
+    public AbstractResultSet(Statement statement) {
+        this.statement = statement;
+    }
+
+    @Override
+    public void close() throws SQLException {
+        isClosed = true;
+    }
+
+    @Override
+    public boolean isClosed() throws SQLException {
+        return isClosed;
+    }
+
+    @Override
+    public int findColumn(String columnLabel) throws SQLException {
+        //aways return first col
+        return 1;
+    }
+
+    @Override
+    public boolean wasNull() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public SQLWarning getWarnings() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public void clearWarnings() throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public int getFetchDirection() throws SQLException {
+        return ResultSet.FETCH_FORWARD;
+    }
+
+    @Override
+    public int getType() throws SQLException {
+        return ResultSet.TYPE_FORWARD_ONLY;
+    }
+
+    @Override
+    public int getConcurrency() throws SQLException {
+        return ResultSet.CONCUR_READ_ONLY;
+    }
+
+    @Override
+    public Statement getStatement() throws SQLException {
+        return statement;
+    }
+
+    @Override
+    public int getHoldability() throws SQLException {
+        return ResultSet.CLOSE_CURSORS_AT_COMMIT;
+    }
+
+    @Override
+    public Object getObject(int columnIndex) throws SQLException {
+        return getString(columnIndex);
+    }
+
+    @Override
+    public Object getObject(String columnLabel) throws SQLException {
+        return getString(columnLabel);
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public final <T> T unwrap(final Class<T> iface) throws SQLException {
+        if (isWrapperFor(iface)) {
+            return (T) this;
+        }
+        throw new SQLException(String.format("[%s] cannot be unwrapped as [%s]", getClass().getName(), iface.getName()));
+    }
+
+    @Override
+    public final boolean isWrapperFor(final Class<?> iface) throws SQLException {
+        return iface.isInstance(this);
+    }
+
+}

+ 124 - 0
src/main/java/org/elasticsearch/jdbc/AbstractStatement.java

@@ -0,0 +1,124 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.*;
+
+public abstract class AbstractStatement extends AbstractFeatureNotSupportedStatement {
+
+    private boolean isClosed = false;
+
+    @Override
+    public void close() throws SQLException {
+        isClosed = true;
+    }
+
+    @Override
+    public int getMaxFieldSize() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public void setMaxFieldSize(int max) throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public int getMaxRows() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public void setMaxRows(int max) throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public void setEscapeProcessing(boolean enable) throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public int getQueryTimeout() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public void setQueryTimeout(int seconds) throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public void cancel() throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public SQLWarning getWarnings() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public void clearWarnings() throws SQLException {
+
+    }
+
+    @Override
+    public void setFetchSize(int rows) throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public int getFetchSize() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getResultSetConcurrency() throws SQLException {
+        return ResultSet.CONCUR_READ_ONLY;
+    }
+
+    @Override
+    public int getResultSetType() throws SQLException {
+        return ResultSet.TYPE_FORWARD_ONLY;
+    }
+
+    @Override
+    public boolean getMoreResults(int current) throws SQLException {
+        return false;
+    }
+
+
+    @Override
+    public int getResultSetHoldability() throws SQLException {
+        return ResultSet.CLOSE_CURSORS_AT_COMMIT;
+    }
+
+    @Override
+    public boolean isClosed() throws SQLException {
+        return isClosed;
+    }
+
+
+    @Override
+    public void setPoolable(boolean poolable) throws SQLException {
+        // ignore
+    }
+
+    @Override
+    public boolean isPoolable() throws SQLException {
+        return false;
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public final <T> T unwrap(final Class<T> iface) throws SQLException {
+        if (isWrapperFor(iface)) {
+            return (T) this;
+        }
+        throw new SQLException(String.format("[%s] cannot be unwrapped as [%s]", getClass().getName(), iface.getName()));
+    }
+
+    @Override
+    public final boolean isWrapperFor(final Class<?> iface) throws SQLException {
+        return iface.isInstance(this);
+    }
+}

+ 0 - 9
src/main/java/org/elasticsearch/jdbc/ConnectionProxy.java

@@ -3,14 +3,5 @@ package org.elasticsearch.jdbc;
 import java.sql.Connection;
 
 public interface ConnectionProxy extends Connection {
-
-    /**
-     * Return the target Connection of this proxy.
-     * <p>This will typically be the native driver Connection
-     * or a wrapper from a connection pool.
-     *
-     * @return the underlying Connection (never {@code null})
-     */
     Connection getTargetConnection();
-
 }

+ 2 - 36
src/main/java/org/elasticsearch/jdbc/DriverManagerDataSource.java

@@ -7,47 +7,21 @@ import java.sql.SQLException;
 import java.util.Properties;
 
 public class DriverManagerDataSource extends AbstractDriverBasedDataSource {
-
-    /**
-     * Constructor for bean-style configuration.
-     */
     public DriverManagerDataSource() {
     }
 
-    /**
-     * Create a new DriverManagerDataSource with the given JDBC URL,
-     * not specifying a username or password for JDBC access.
-     *
-     * @param url the JDBC URL to use for accessing the DriverManager
-     * @see java.sql.DriverManager#getConnection(String)
-     */
+
     public DriverManagerDataSource(String url) {
         setUrl(url);
     }
 
-    /**
-     * Create a new DriverManagerDataSource with the given standard
-     * DriverManager parameters.
-     *
-     * @param url      the JDBC URL to use for accessing the DriverManager
-     * @param username the JDBC username to use for accessing the DriverManager
-     * @param password the JDBC password to use for accessing the DriverManager
-     * @see java.sql.DriverManager#getConnection(String, String, String)
-     */
+
     public DriverManagerDataSource(String url, String username, String password) {
         setUrl(url);
         setUsername(username);
         setPassword(password);
     }
 
-    /**
-     * Create a new DriverManagerDataSource with the given JDBC URL,
-     * not specifying a username or password for JDBC access.
-     *
-     * @param url      the JDBC URL to use for accessing the DriverManager
-     * @param conProps JDBC connection properties
-     * @see java.sql.DriverManager#getConnection(String)
-     */
     public DriverManagerDataSource(String url, Properties conProps) {
         setUrl(url);
         setConnectionProperties(conProps);
@@ -62,7 +36,6 @@ public class DriverManagerDataSource extends AbstractDriverBasedDataSource {
     }
 
 
-
     public void setDriverClassName(String driverClassName) {
         String driverClassNameToUse = driverClassName.trim();
         try {
@@ -101,16 +74,9 @@ public class DriverManagerDataSource extends AbstractDriverBasedDataSource {
     @Override
     protected Connection getConnectionFromDriver(Properties props) throws SQLException {
         String url = getUrl();
-
         return getConnectionFromDriverManager(url, props);
     }
 
-    /**
-     * Getting a Connection using the nasty static from DriverManager is extracted
-     * into a protected method to allow for easy unit testing.
-     *
-     * @see java.sql.DriverManager#getConnection(String, java.util.Properties)
-     */
     protected Connection getConnectionFromDriverManager(String url, Properties props) throws SQLException {
         return DriverManager.getConnection(url, props);
     }

文件差異過大導致無法顯示
+ 18 - 1505
src/main/java/org/elasticsearch/jdbc/ElasticConnection.java


+ 892 - 0
src/main/java/org/elasticsearch/jdbc/ElasticDatabaseMetaData.java

@@ -0,0 +1,892 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.*;
+
+public class ElasticDatabaseMetaData implements DatabaseMetaData {
+
+    private String url;
+
+    public ElasticDatabaseMetaData(String url) {
+        this.url = url;
+    }
+
+    @Override
+    public boolean allProceduresAreCallable() throws SQLException {
+        return true;
+    }
+
+    @Override
+    public boolean allTablesAreSelectable() throws SQLException {
+        return true;
+    }
+
+    @Override
+    public String getURL() throws SQLException {
+        return url;
+    }
+
+    @Override
+    public String getUserName() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean isReadOnly() throws SQLException {
+        return true;
+    }
+
+    @Override
+    public boolean nullsAreSortedHigh() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean nullsAreSortedLow() throws SQLException {
+        return true;
+    }
+
+    @Override
+    public boolean nullsAreSortedAtStart() throws SQLException {
+        return nullsAreSortedHigh();
+    }
+
+    @Override
+    public boolean nullsAreSortedAtEnd() throws SQLException {
+        return nullsAreSortedLow();
+    }
+
+    @Override
+    public String getDatabaseProductName() throws SQLException {
+        return "elasticsearch_2.4.4";
+    }
+
+    @Override
+    public String getDatabaseProductVersion() throws SQLException {
+        return "2.4.5";
+    }
+
+    @Override
+    public String getDriverName() throws SQLException {
+        return "org.elasticsearch.jdbc.ElasticDriver";
+    }
+
+    @Override
+    public String getDriverVersion() throws SQLException {
+        return "1.0";
+    }
+
+    @Override
+    public int getDriverMajorVersion() {
+        return 1;
+    }
+
+    @Override
+    public int getDriverMinorVersion() {
+        return 0;
+    }
+
+    @Override
+    public boolean usesLocalFiles() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean usesLocalFilePerTable() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMixedCaseIdentifiers() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean storesUpperCaseIdentifiers() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean storesLowerCaseIdentifiers() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean storesMixedCaseIdentifiers() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public String getIdentifierQuoteString() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getSQLKeywords() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getNumericFunctions() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getStringFunctions() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getSystemFunctions() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getTimeDateFunctions() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getSearchStringEscape() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getExtraNameCharacters() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean supportsAlterTableWithAddColumn() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsAlterTableWithDropColumn() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsColumnAliasing() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean nullPlusNonNullIsNull() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsConvert() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsConvert(int fromType, int toType) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsTableCorrelationNames() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsDifferentTableCorrelationNames() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsExpressionsInOrderBy() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsOrderByUnrelated() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsGroupBy() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsGroupByUnrelated() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsGroupByBeyondSelect() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsLikeEscapeClause() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMultipleResultSets() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMultipleTransactions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsNonNullableColumns() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMinimumSQLGrammar() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsCoreSQLGrammar() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsExtendedSQLGrammar() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsANSI92EntryLevelSQL() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsANSI92IntermediateSQL() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsANSI92FullSQL() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsIntegrityEnhancementFacility() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsOuterJoins() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsFullOuterJoins() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsLimitedOuterJoins() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public String getSchemaTerm() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getProcedureTerm() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getCatalogTerm() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean isCatalogAtStart() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public String getCatalogSeparator() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean supportsSchemasInDataManipulation() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSchemasInProcedureCalls() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSchemasInTableDefinitions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSchemasInIndexDefinitions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsCatalogsInDataManipulation() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsCatalogsInProcedureCalls() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsCatalogsInTableDefinitions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsPositionedDelete() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsPositionedUpdate() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSelectForUpdate() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsStoredProcedures() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSubqueriesInComparisons() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSubqueriesInExists() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSubqueriesInIns() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsSubqueriesInQuantifieds() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsCorrelatedSubqueries() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsUnion() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsUnionAll() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public int getMaxBinaryLiteralLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxCharLiteralLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxColumnNameLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxColumnsInGroupBy() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxColumnsInIndex() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxColumnsInOrderBy() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxColumnsInSelect() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxColumnsInTable() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxConnections() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxCursorNameLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxIndexLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxSchemaNameLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxProcedureNameLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxCatalogNameLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxRowSize() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public boolean doesMaxRowSizeIncludeBlobs() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public int getMaxStatementLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxStatements() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxTableNameLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxTablesInSelect() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getMaxUserNameLength() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getDefaultTransactionIsolation() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public boolean supportsTransactions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsTransactionIsolationLevel(int level) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean dataDefinitionCausesTransactionCommit() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean dataDefinitionIgnoredInTransactions() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public ResultSet getProcedures(String catalog, String schemaPattern, String procedureNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getProcedureColumns(String catalog, String schemaPattern, String procedureNamePattern, String columnNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getSchemas() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getCatalogs() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getTableTypes() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getColumnPrivileges(String catalog, String schema, String table, String columnNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getTablePrivileges(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getBestRowIdentifier(String catalog, String schema, String table, int scope, boolean nullable) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getVersionColumns(String catalog, String schema, String table) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getPrimaryKeys(String catalog, String schema, String table) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getImportedKeys(String catalog, String schema, String table) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getExportedKeys(String catalog, String schema, String table) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getCrossReference(String parentCatalog, String parentSchema, String parentTable, String foreignCatalog, String foreignSchema, String foreignTable) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getTypeInfo() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getIndexInfo(String catalog, String schema, String table, boolean unique, boolean approximate) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean supportsResultSetType(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsResultSetConcurrency(int type, int concurrency) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean ownUpdatesAreVisible(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean ownDeletesAreVisible(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean ownInsertsAreVisible(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean othersUpdatesAreVisible(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean othersDeletesAreVisible(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean othersInsertsAreVisible(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean updatesAreDetected(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean deletesAreDetected(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean insertsAreDetected(int type) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsBatchUpdates() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public ResultSet getUDTs(String catalog, String schemaPattern, String typeNamePattern, int[] types) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public Connection getConnection() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean supportsSavepoints() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsNamedParameters() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsMultipleOpenResults() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsGetGeneratedKeys() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public ResultSet getSuperTypes(String catalog, String schemaPattern, String typeNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getSuperTables(String catalog, String schemaPattern, String tableNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getAttributes(String catalog, String schemaPattern, String typeNamePattern, String attributeNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean supportsResultSetHoldability(int holdability) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public int getResultSetHoldability() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getDatabaseMajorVersion() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getDatabaseMinorVersion() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getJDBCMajorVersion() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getJDBCMinorVersion() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getSQLStateType() throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public boolean locatorsUpdateCopy() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean supportsStatementPooling() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public RowIdLifetime getRowIdLifetime() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean autoCommitFailureClosesAllResultSets() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public ResultSet getClientInfoProperties() throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getFunctions(String catalog, String schemaPattern, String functionNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getFunctionColumns(String catalog, String schemaPattern, String functionNamePattern, String columnNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public ResultSet getPseudoColumns(String catalog, String schemaPattern, String tableNamePattern, String columnNamePattern) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean generatedKeyAlwaysReturned() throws SQLException {
+        return false;
+    }
+
+    @Override
+    public <T> T unwrap(Class<T> iface) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public boolean isWrapperFor(Class<?> iface) throws SQLException {
+        return false;
+    }
+}

+ 11 - 5
src/main/java/org/elasticsearch/jdbc/ElasticDriver.java

@@ -1,5 +1,7 @@
 package org.elasticsearch.jdbc;
 
+import org.elasticsearch.client.Client;
+
 import java.sql.*;
 import java.util.Properties;
 import java.util.logging.Logger;
@@ -8,24 +10,28 @@ public class ElasticDriver implements Driver {
 
     private static final String ELASTIC_SEARCH_DRIVER_PREFIX = "jdbc:elastic:";
 
-    private static final ElasticDriver driverInstance;
+    private Client client;
 
     static {
-        driverInstance = new ElasticDriver();
         try {
-            DriverManager.registerDriver(driverInstance);
+            DriverManager.registerDriver(new ElasticDriver());
         }
         catch (SQLException ex) {
             // ignore
         }
     }
 
+    private ElasticDriver() {
+
+    }
+
     @Override
     public Connection connect(String url, Properties info) throws SQLException {
-        return new ElasticConnection();
+        String ipUrl = url.substring(ELASTIC_SEARCH_DRIVER_PREFIX.length() - 1);
+        Client client = TransportClientFactory.createTransportClientFromUrl(url);
+        return new ElasticConnection(url, info, client);
     }
 
-
     @Override
     public boolean acceptsURL(String url) throws SQLException {
         return url != null && url.startsWith(ELASTIC_SEARCH_DRIVER_PREFIX);

+ 60 - 0
src/main/java/org/elasticsearch/jdbc/ElasticResultSet.java

@@ -0,0 +1,60 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+public class ElasticResultSet extends AbstractResultSet {
+
+    public static final ElasticResultSetMetaData resultSetMetaData = new ElasticResultSetMetaData();
+
+    private String searchResultJson;
+
+    private int rowCursor = 0;
+
+    public ElasticResultSet(Statement statement, String searchResultJson) {
+        super(statement);
+        this.searchResultJson = searchResultJson;
+    }
+
+    @Override
+    public boolean next() throws SQLException {
+        rowCursor++;
+        return rowCursor <= 1;
+    }
+
+    @Override
+    public void beforeFirst() throws SQLException {
+        rowCursor = 0;
+    }
+
+    @Override
+    public void afterLast() throws SQLException {
+        rowCursor = 1;
+    }
+
+    @Override
+    public String getString(int columnIndex) throws SQLException {
+        return searchResultJson;
+    }
+
+    @Override
+    public String getString(String columnLabel) throws SQLException {
+        return searchResultJson;
+    }
+
+    @Override
+    public int getRow() throws SQLException {
+        return rowCursor;
+    }
+
+    @Override
+    public int getFetchSize() throws SQLException {
+        return 1;
+    }
+
+    @Override
+    public ResultSetMetaData getMetaData() throws SQLException {
+        return resultSetMetaData;
+    }
+}

+ 132 - 0
src/main/java/org/elasticsearch/jdbc/ElasticResultSetMetaData.java

@@ -0,0 +1,132 @@
+package org.elasticsearch.jdbc;
+
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Types;
+
+public class ElasticResultSetMetaData implements ResultSetMetaData {
+
+    protected static final String JSON_DATA_COL_NAME = "json_result";
+
+    @Override
+    public int getColumnCount() throws SQLException {
+        return 1;
+    }
+
+    @Override
+    public boolean isAutoIncrement(int column) throws SQLException {
+        return true;
+    }
+
+    @Override
+    public boolean isCaseSensitive(int column) throws SQLException {
+        return true;
+    }
+
+    @Override
+    public boolean isSearchable(int column) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean isCurrency(int column) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public int isNullable(int column) throws SQLException {
+        return columnNoNulls;
+    }
+
+    @Override
+    public boolean isSigned(int column) throws SQLException {
+        return false;
+    }
+
+
+    @Override
+    public int getColumnDisplaySize(int column) throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public String getColumnLabel(int column) throws SQLException {
+        return JSON_DATA_COL_NAME;
+    }
+
+    @Override
+    public String getColumnName(int column) throws SQLException {
+        return JSON_DATA_COL_NAME;
+    }
+
+    @Override
+    public String getSchemaName(int column) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public int getPrecision(int column) throws SQLException {
+        return 0;
+    }
+
+    @Override
+    public int getScale(int column) throws SQLException {
+        return 0;
+    }
+
+
+    @Override
+    public String getTableName(int column) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public String getCatalogName(int column) throws SQLException {
+        return null;
+    }
+
+    @Override
+    public int getColumnType(int column) throws SQLException {
+        return Types.VARCHAR;
+    }
+
+    @Override
+    public String getColumnTypeName(int column) throws SQLException {
+        return "String";
+    }
+
+    @Override
+    public boolean isReadOnly(int column) throws SQLException {
+        return true;
+    }
+
+
+    @Override
+    public boolean isWritable(int column) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public boolean isDefinitelyWritable(int column) throws SQLException {
+        return false;
+    }
+
+    @Override
+    public String getColumnClassName(int column) throws SQLException {
+        return String.class.toString();
+    }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public final <T> T unwrap(final Class<T> iface) throws SQLException {
+        if (isWrapperFor(iface)) {
+            return (T) this;
+        }
+        throw new SQLException(String.format("[%s] cannot be unwrapped as [%s]", getClass().getName(), iface.getName()));
+    }
+
+    @Override
+    public final boolean isWrapperFor(final Class<?> iface) throws SQLException {
+        return iface.isInstance(this);
+    }
+}

+ 195 - 0
src/main/java/org/elasticsearch/jdbc/ElasticSingleConnectionDataSource.java

@@ -0,0 +1,195 @@
+package org.elasticsearch.jdbc;
+
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.sql.Connection;
+import java.sql.SQLException;
+
+public class ElasticSingleConnectionDataSource extends DriverManagerDataSource implements SmartDataSource {
+
+    private boolean suppressClose;
+
+    private Connection target;
+
+    private Connection connection;
+
+    private final Object connectionMonitor = new Object();
+
+    public ElasticSingleConnectionDataSource() {
+
+    }
+
+    public ElasticSingleConnectionDataSource(String url, boolean suppressClose) {
+        super(url);
+        this.suppressClose = suppressClose;
+    }
+
+    public ElasticSingleConnectionDataSource(Connection target, boolean suppressClose) {
+        this.target = target;
+        this.suppressClose = suppressClose;
+        this.connection = (suppressClose ? getCloseSuppressingConnectionProxy(target) : target);
+    }
+
+    public ElasticSingleConnectionDataSource(String url, String username, String password, boolean suppressClose) {
+        super(url, username, password);
+        this.suppressClose = suppressClose;
+    }
+
+    public void setSuppressClose(boolean suppressClose) {
+        this.suppressClose = suppressClose;
+    }
+
+
+    protected boolean isSuppressClose() {
+        return this.suppressClose;
+    }
+
+
+    public void setAutoCommit(boolean autoCommit) {
+        // ignore
+    }
+
+
+    protected Boolean getAutoCommitValue() {
+        return Boolean.FALSE;
+    }
+
+
+    @Override
+    public Connection getConnection() throws SQLException {
+        synchronized (this.connectionMonitor) {
+            if (this.connection == null) {
+                // No underlying Connection -> lazy init via DriverManager.
+                initConnection();
+            }
+            if (this.connection.isClosed()) {
+                throw new SQLException(
+                        "Connection was closed in ElasticSingleConnectionDataSource. Check that user code checks " +
+                                "shouldClose() before closing Connections, or set 'suppressClose' to 'true'");
+            }
+            return this.connection;
+        }
+    }
+
+    @Override
+    public Connection getConnection(String username, String password) throws SQLException {
+        return getConnection();
+    }
+
+
+    public boolean shouldClose(Connection con) {
+        synchronized (this.connectionMonitor) {
+            return (con != this.connection && con != this.target);
+        }
+    }
+
+    public void destroy() {
+        synchronized (this.connectionMonitor) {
+            closeConnection();
+        }
+    }
+
+
+    public void initConnection() throws SQLException {
+        if (getUrl() == null) {
+            throw new IllegalStateException("'url' property is required for lazily initializing a Connection");
+        }
+        synchronized (this.connectionMonitor) {
+            closeConnection();
+            this.target = getConnectionFromDriver(getUsername(), getPassword());
+            prepareConnection(this.target);
+            this.connection = (isSuppressClose() ? getCloseSuppressingConnectionProxy(this.target) : this.target);
+        }
+    }
+
+
+    public void resetConnection() {
+        synchronized (this.connectionMonitor) {
+            closeConnection();
+            this.target = null;
+            this.connection = null;
+        }
+    }
+
+
+    protected void prepareConnection(Connection con) throws SQLException {
+        Boolean autoCommit = getAutoCommitValue();
+        if (autoCommit != null && con.getAutoCommit() != autoCommit) {
+            con.setAutoCommit(autoCommit);
+        }
+    }
+
+
+    private void closeConnection() {
+        if (this.target != null) {
+            try {
+                this.target.close();
+            }
+            catch (Throwable ex) {
+                //logger.warn("Could not close shared JDBC Connection", ex);
+            }
+        }
+    }
+
+
+    protected Connection getCloseSuppressingConnectionProxy(Connection target) {
+        return (Connection) Proxy.newProxyInstance(
+                ConnectionProxy.class.getClassLoader(),
+                new Class[]{ConnectionProxy.class},
+                new CloseSuppressingInvocationHandler(target));
+    }
+
+
+    private static class CloseSuppressingInvocationHandler implements InvocationHandler {
+        private final Connection target;
+        public CloseSuppressingInvocationHandler(Connection target) {
+            this.target = target;
+        }
+
+        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+            // Invocation on ConnectionProxy interface coming in...
+
+            if (method.getName().equals("equals")) {
+                // Only consider equal when proxies are identical.
+                return (proxy == args[0]);
+            }
+            else if (method.getName().equals("hashCode")) {
+                // Use hashCode of Connection proxy.
+                return System.identityHashCode(proxy);
+            }
+            else if (method.getName().equals("unwrap")) {
+                if (((Class) args[0]).isInstance(proxy)) {
+                    return proxy;
+                }
+            }
+            else if (method.getName().equals("isWrapperFor")) {
+                if (((Class) args[0]).isInstance(proxy)) {
+                    return true;
+                }
+            }
+            else if (method.getName().equals("close")) {
+                // Handle close method: don't pass the call on.
+                return null;
+            }
+            else if (method.getName().equals("isClosed")) {
+                return false;
+            }
+            else if (method.getName().equals("getTargetConnection")) {
+                // Handle getTargetConnection method: return underlying Connection.
+                return this.target;
+            }
+
+            // Invoke method on target Connection.
+            try {
+                return method.invoke(this.target, args);
+            }
+            catch (InvocationTargetException ex) {
+                throw ex.getTargetException();
+            }
+        }
+    }
+
+}

+ 47 - 0
src/main/java/org/elasticsearch/jdbc/ElasticStatement.java

@@ -0,0 +1,47 @@
+package org.elasticsearch.jdbc;
+
+import org.elasticsearch.action.search.SearchRequestBuilder;
+import org.elasticsearch.action.search.SearchResponse;
+import org.elasticsearch.dsl.bean.ElasticSqlParseResult;
+import org.elasticsearch.dsl.parser.ElasticSql2DslParser;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+public class ElasticStatement extends AbstractStatement {
+
+    protected ElasticConnection connection;
+
+    public ElasticStatement(ElasticConnection connection) {
+        this.connection = connection;
+    }
+
+    private ResultSet executeResult;
+
+    @Override
+    public ResultSet executeQuery(String sql) throws SQLException {
+        ElasticSql2DslParser sql2DslParser = new ElasticSql2DslParser();
+        ElasticSqlParseResult parseResult = sql2DslParser.parse(sql);
+        SearchRequestBuilder searchRequest = parseResult.toRequest(connection.getClient());
+        SearchResponse searchResponse = searchRequest.execute().actionGet();
+
+        return executeResult = new ElasticResultSet(this, searchResponse.toString());
+    }
+
+    @Override
+    public boolean execute(String sql) throws SQLException {
+        executeQuery(sql);
+        return true;
+    }
+
+    @Override
+    public ResultSet getResultSet() throws SQLException {
+        return executeResult;
+    }
+
+    @Override
+    public Connection getConnection() throws SQLException {
+        return connection;
+    }
+}

+ 0 - 319
src/main/java/org/elasticsearch/jdbc/SingleConnectionDataSource.java

@@ -1,319 +0,0 @@
-package org.elasticsearch.jdbc;
-
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.Connection;
-import java.sql.SQLException;
-
-public class SingleConnectionDataSource extends DriverManagerDataSource implements SmartDataSource {
-
-    /**
-     * Create a close-suppressing proxy?
-     */
-    private boolean suppressClose;
-
-    /**
-     * Override auto-commit state?
-     */
-    private Boolean autoCommit;
-
-    /**
-     * Wrapped Connection
-     */
-    private Connection target;
-
-    /**
-     * Proxy Connection
-     */
-    private Connection connection;
-
-    /**
-     * Synchronization monitor for the shared Connection
-     */
-    private final Object connectionMonitor = new Object();
-
-
-    /**
-     * Constructor for bean-style configuration.
-     */
-    public SingleConnectionDataSource() {
-    }
-
-    /**
-     * Create a new SingleConnectionDataSource with the given standard
-     * DriverManager parameters.
-     *
-     * @param driverClassName the JDBC driver class name
-     * @param url             the JDBC URL to use for accessing the DriverManager
-     * @param username        the JDBC username to use for accessing the DriverManager
-     * @param password        the JDBC password to use for accessing the DriverManager
-     * @param suppressClose   if the returned Connection should be a
-     *                        close-suppressing proxy or the physical Connection
-     * @see java.sql.DriverManager#getConnection(String, String, String)
-     * @deprecated since Spring 2.5. Driver parameter usage is generally not recommended
-     * for a SingleConnectionDataSource. If you insist on using driver parameters
-     * directly, set up the Driver class manually before invoking this DataSource.
-     */
-    @Deprecated
-    public SingleConnectionDataSource(
-            String driverClassName, String url, String username, String password, boolean suppressClose) {
-
-        super(driverClassName, url, username, password);
-        this.suppressClose = suppressClose;
-    }
-
-    /**
-     * Create a new SingleConnectionDataSource with the given standard
-     * DriverManager parameters.
-     *
-     * @param url           the JDBC URL to use for accessing the DriverManager
-     * @param username      the JDBC username to use for accessing the DriverManager
-     * @param password      the JDBC password to use for accessing the DriverManager
-     * @param suppressClose if the returned Connection should be a
-     *                      close-suppressing proxy or the physical Connection
-     * @see java.sql.DriverManager#getConnection(String, String, String)
-     */
-    public SingleConnectionDataSource(String url, String username, String password, boolean suppressClose) {
-        super(url, username, password);
-        this.suppressClose = suppressClose;
-    }
-
-    /**
-     * Create a new SingleConnectionDataSource with the given standard
-     * DriverManager parameters.
-     *
-     * @param url           the JDBC URL to use for accessing the DriverManager
-     * @param suppressClose if the returned Connection should be a
-     *                      close-suppressing proxy or the physical Connection
-     * @see java.sql.DriverManager#getConnection(String, String, String)
-     */
-    public SingleConnectionDataSource(String url, boolean suppressClose) {
-        super(url);
-        this.suppressClose = suppressClose;
-    }
-
-    /**
-     * Create a new SingleConnectionDataSource with a given Connection.
-     *
-     * @param target        underlying target Connection
-     * @param suppressClose if the Connection should be wrapped with a Connection that
-     *                      suppresses {@code close()} calls (to allow for normal {@code close()}
-     *                      usage in applications that expect a pooled Connection but do not know our
-     *                      SmartDataSource interface)
-     */
-    public SingleConnectionDataSource(Connection target, boolean suppressClose) {
-        this.target = target;
-        this.suppressClose = suppressClose;
-        this.connection = (suppressClose ? getCloseSuppressingConnectionProxy(target) : target);
-    }
-
-
-    /**
-     * Set whether the returned Connection should be a close-suppressing proxy
-     * or the physical Connection.
-     */
-    public void setSuppressClose(boolean suppressClose) {
-        this.suppressClose = suppressClose;
-    }
-
-    /**
-     * Return whether the returned Connection will be a close-suppressing proxy
-     * or the physical Connection.
-     */
-    protected boolean isSuppressClose() {
-        return this.suppressClose;
-    }
-
-    /**
-     * Set whether the returned Connection's "autoCommit" setting should be overridden.
-     */
-    public void setAutoCommit(boolean autoCommit) {
-        this.autoCommit = (autoCommit);
-    }
-
-    /**
-     * Return whether the returned Connection's "autoCommit" setting should be overridden.
-     *
-     * @return the "autoCommit" value, or {@code null} if none to be applied
-     */
-    protected Boolean getAutoCommitValue() {
-        return this.autoCommit;
-    }
-
-
-    @Override
-    public Connection getConnection() throws SQLException {
-        synchronized (this.connectionMonitor) {
-            if (this.connection == null) {
-                // No underlying Connection -> lazy init via DriverManager.
-                initConnection();
-            }
-            if (this.connection.isClosed()) {
-                throw new SQLException(
-                        "Connection was closed in SingleConnectionDataSource. Check that user code checks " +
-                                "shouldClose() before closing Connections, or set 'suppressClose' to 'true'");
-            }
-            return this.connection;
-        }
-    }
-
-    /**
-     * Specifying a custom username and password doesn't make sense
-     * with a single Connection. Returns the single Connection if given
-     * the same username and password; throws a SQLException else.
-     */
-    @Override
-    public Connection getConnection(String username, String password) throws SQLException {
-        return getConnection();
-    }
-
-    /**
-     * This is a single Connection: Do not close it when returning to the "pool".
-     */
-    public boolean shouldClose(Connection con) {
-        synchronized (this.connectionMonitor) {
-            return (con != this.connection && con != this.target);
-        }
-    }
-
-    /**
-     * Close the underlying Connection.
-     * The provider of this DataSource needs to care for proper shutdown.
-     * <p>As this bean implements DisposableBean, a bean factory will
-     * automatically invoke this on destruction of its cached singletons.
-     */
-    public void destroy() {
-        synchronized (this.connectionMonitor) {
-            closeConnection();
-        }
-    }
-
-
-    /**
-     * Initialize the underlying Connection via the DriverManager.
-     */
-    public void initConnection() throws SQLException {
-        if (getUrl() == null) {
-            throw new IllegalStateException("'url' property is required for lazily initializing a Connection");
-        }
-        synchronized (this.connectionMonitor) {
-            closeConnection();
-            this.target = getConnectionFromDriver(getUsername(), getPassword());
-            prepareConnection(this.target);
-            this.connection = (isSuppressClose() ? getCloseSuppressingConnectionProxy(this.target) : this.target);
-        }
-    }
-
-    /**
-     * Reset the underlying shared Connection, to be reinitialized on next access.
-     */
-    public void resetConnection() {
-        synchronized (this.connectionMonitor) {
-            closeConnection();
-            this.target = null;
-            this.connection = null;
-        }
-    }
-
-    /**
-     * Prepare the given Connection before it is exposed.
-     * <p>The default implementation applies the auto-commit flag, if necessary.
-     * Can be overridden in subclasses.
-     *
-     * @param con the Connection to prepare
-     * @see #setAutoCommit
-     */
-    protected void prepareConnection(Connection con) throws SQLException {
-        Boolean autoCommit = getAutoCommitValue();
-        if (autoCommit != null && con.getAutoCommit() != autoCommit) {
-            con.setAutoCommit(autoCommit);
-        }
-    }
-
-    /**
-     * Close the underlying shared Connection.
-     */
-    private void closeConnection() {
-        if (this.target != null) {
-            try {
-                this.target.close();
-            }
-            catch (Throwable ex) {
-                //logger.warn("Could not close shared JDBC Connection", ex);
-            }
-        }
-    }
-
-    /**
-     * Wrap the given Connection with a proxy that delegates every method call to it
-     * but suppresses close calls.
-     *
-     * @param target the original Connection to wrap
-     * @return the wrapped Connection
-     */
-    protected Connection getCloseSuppressingConnectionProxy(Connection target) {
-        return (Connection) Proxy.newProxyInstance(
-                ConnectionProxy.class.getClassLoader(),
-                new Class[]{ConnectionProxy.class},
-                new CloseSuppressingInvocationHandler(target));
-    }
-
-
-    /**
-     * Invocation handler that suppresses close calls on JDBC Connections.
-     */
-    private static class CloseSuppressingInvocationHandler implements InvocationHandler {
-
-        private final Connection target;
-
-        public CloseSuppressingInvocationHandler(Connection target) {
-            this.target = target;
-        }
-
-        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-            // Invocation on ConnectionProxy interface coming in...
-
-            if (method.getName().equals("equals")) {
-                // Only consider equal when proxies are identical.
-                return (proxy == args[0]);
-            }
-            else if (method.getName().equals("hashCode")) {
-                // Use hashCode of Connection proxy.
-                return System.identityHashCode(proxy);
-            }
-            else if (method.getName().equals("unwrap")) {
-                if (((Class) args[0]).isInstance(proxy)) {
-                    return proxy;
-                }
-            }
-            else if (method.getName().equals("isWrapperFor")) {
-                if (((Class) args[0]).isInstance(proxy)) {
-                    return true;
-                }
-            }
-            else if (method.getName().equals("close")) {
-                // Handle close method: don't pass the call on.
-                return null;
-            }
-            else if (method.getName().equals("isClosed")) {
-                return false;
-            }
-            else if (method.getName().equals("getTargetConnection")) {
-                // Handle getTargetConnection method: return underlying Connection.
-                return this.target;
-            }
-
-            // Invoke method on target Connection.
-            try {
-                return method.invoke(this.target, args);
-            }
-            catch (InvocationTargetException ex) {
-                throw ex.getTargetException();
-            }
-        }
-    }
-
-}

+ 44 - 0
src/main/java/org/elasticsearch/jdbc/TransportClientFactory.java

@@ -0,0 +1,44 @@
+package org.elasticsearch.jdbc;
+
+import com.google.common.collect.Maps;
+import org.elasticsearch.client.transport.TransportClient;
+import org.elasticsearch.common.settings.Settings;
+import org.elasticsearch.common.transport.InetSocketTransportAddress;
+
+import java.net.InetSocketAddress;
+import java.util.Map;
+
+public class TransportClientFactory {
+
+    private static final String COMMA = ",";
+
+    private static final Map<String, TransportClient> clientMap = Maps.newConcurrentMap();
+
+    private TransportClientFactory() {
+
+    }
+
+    public static TransportClient createTransportClientFromUrl(String url) {
+        if (clientMap.containsKey(url)) {
+            return clientMap.get(url);
+        }
+
+        String[] connStringList = url.split(COMMA);
+        for (String connStr : connStringList) {
+            String[] connArr = connStr.split(":");
+        }
+
+
+        Settings settings = Settings.settingsBuilder()
+                .put("cluster.name", "elasticsearch_wenbronk")
+                .put("client.transport.sniff", true)
+                .build();
+
+        TransportClient transportClient = TransportClient.builder().settings(settings).build()
+                .addTransportAddress(new InetSocketTransportAddress(new InetSocketAddress("192.168.50.37", 9300)));
+
+        clientMap.put(url, transportClient);
+
+        return clientMap.get(url);
+    }
+}

+ 34 - 3
src/test/java/org/elasticsearch/jdbc/ElasticDriverTest.java

@@ -6,12 +6,17 @@ import org.junit.Test;
 import java.sql.Connection;
 import java.sql.Driver;
 import java.sql.DriverManager;
+import java.sql.ResultSet;
 import java.util.Enumeration;
 
 public class ElasticDriverTest {
+    private static final String driver = "org.elasticsearch.jdbc.ElasticDriver";
+    private static final String url = "jdbc:elastic:192.168.0.1:9200";
+
+
     @Test
     public void testLoadDriver() throws Exception {
-        Class.forName("org.elasticsearch.jdbc.ElasticDriver");
+        Class.forName(driver);
 
         Enumeration<Driver> driverEnumeration = DriverManager.getDrivers();
 
@@ -23,8 +28,34 @@ public class ElasticDriverTest {
 
     @Test
     public void testGetConnection() throws Exception {
-        Class.forName("org.elasticsearch.jdbc.ElasticDriver");
-        Connection connection = DriverManager.getConnection("jdbc:elastic:192.168.0.1:9200");
+        Class.forName(driver);
+        Connection connection = DriverManager.getConnection(url);
+        org.junit.Assert.assertTrue(connection instanceof ElasticConnection);
+    }
+
+    @Test
+    public void testDataSource() throws Exception {
+        ElasticSingleConnectionDataSource dataSource = new ElasticSingleConnectionDataSource(url, false);
+        dataSource.setDriverClassName(driver);
+
+        Connection connection = dataSource.getConnection();
         org.junit.Assert.assertTrue(connection instanceof ElasticConnection);
+
+        dataSource.destroy();
+        org.junit.Assert.assertTrue(connection.isClosed());
+    }
+
+    @Test
+    public void testQuery() throws Exception {
+        ElasticSingleConnectionDataSource dataSource = new ElasticSingleConnectionDataSource(url, true);
+        dataSource.setDriverClassName(driver);
+
+        Connection connection = dataSource.getConnection();
+        ResultSet resultSet = connection.createStatement().executeQuery("select * from reserve_record.rsr_plan_work_inst where id > 0");
+
+        while(resultSet.next()) {
+            String json = resultSet.getString(1);
+            System.out.println(json);
+        }
     }
 }

+ 1 - 1
src/test/java/org/elasticsearch/query/SqlParserWhereConditionTest.java

@@ -10,7 +10,7 @@ import org.elasticsearch.index.query.QueryBuilders;
 import org.elasticsearch.search.aggregations.AbstractAggregationBuilder;
 import org.elasticsearch.search.aggregations.AggregationBuilders;
 import org.elasticsearch.search.aggregations.bucket.terms.TermsBuilder;
-import org.elasticsearch.util.ElasticMockClient;
+import org.elasticsearch.client.ElasticMockClient;
 import org.junit.Assert;
 import org.junit.Test;