| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- 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 false;
- }
- @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
- }
- }
|