package test

import java.sql.Array
import java.sql.Blob
import java.sql.CallableStatement
import java.sql.Clob
import java.sql.Connection
import java.sql.DatabaseMetaData
import java.sql.NClob
import java.sql.PreparedStatement
import java.sql.SQLClientInfoException
import java.sql.SQLException
import java.sql.SQLWarning
import java.sql.SQLXML
import java.sql.Savepoint
import java.sql.Statement
import java.sql.Struct
import java.util.concurrent.Executor

class WrappedConnection implements Connection {
  Connection delegate

  WrappedConnection(Connection delegate) {
    this.delegate = delegate
  }

  def <T> T unwrap(Class<T> iface) throws SQLException {
    if (!isWrapperFor(iface)) {
      throw new SQLException("Not a wrapper for interface")
    }
    return delegate as T
  }

  boolean isWrapperFor(Class<?> iface) throws SQLException {
    return Connection == iface
  }

  Statement createStatement() throws SQLException {
    return delegate.createStatement()
  }

  PreparedStatement prepareStatement(String sql) throws SQLException {
    return delegate.prepareStatement(sql)
  }

  CallableStatement prepareCall(String sql) throws SQLException {
    return delegate.prepareCall(sql)
  }

  String nativeSQL(String sql) throws SQLException {
    return delegate.nativeSQL(sql)
  }

  void setAutoCommit(boolean autoCommit) throws SQLException {
    delegate.setAutoCommit(autoCommit)
  }

  boolean getAutoCommit() throws SQLException {
    return delegate.getAutoCommit()
  }

  void commit() throws SQLException {
    delegate.commit()
  }

  void rollback() throws SQLException {
    delegate.rollback()
  }

  void close() throws SQLException {
    delegate.close()
  }

  boolean isClosed() throws SQLException {
    return delegate.isClosed()
  }

  DatabaseMetaData getMetaData() throws SQLException {
    return delegate.getMetaData()
  }

  void setReadOnly(boolean readOnly) throws SQLException {
    delegate.setReadOnly(readOnly)
  }

  boolean isReadOnly() throws SQLException {
    return delegate.isReadOnly()
  }

  void setCatalog(String catalog) throws SQLException {
    delegate.setCatalog(catalog)
  }

  String getCatalog() throws SQLException {
    return delegate.getCatalog()
  }

  void setTransactionIsolation(int level) throws SQLException {
    delegate.setTransactionIsolation(level)
  }

  int getTransactionIsolation() throws SQLException {
    return delegate.getTransactionIsolation()
  }

  SQLWarning getWarnings() throws SQLException {
    return delegate.getWarnings()
  }

  void clearWarnings() throws SQLException {
    delegate.clearWarnings()
  }

  Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
    return delegate.createStatement(resultSetType, resultSetConcurrency)
  }

  PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
    return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency)
  }

  CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
    return delegate.prepareCall(sql, resultSetType, resultSetConcurrency)
  }

  Map<String, Class<?>> getTypeMap() throws SQLException {
    return delegate.getTypeMap()
  }

  void setTypeMap(Map<String, Class<?>> map) throws SQLException {
    delegate.setTypeMap(map)
  }

  void setHoldability(int holdability) throws SQLException {
    delegate.setHoldability(holdability)
  }

  int getHoldability() throws SQLException {
    return delegate.getHoldability()
  }

  Savepoint setSavepoint() throws SQLException {
    return delegate.setSavepoint()
  }

  Savepoint setSavepoint(String name) throws SQLException {
    return delegate.setSavepoint(name)
  }

  void rollback(Savepoint savepoint) throws SQLException {
    delegate.rollback(savepoint)
  }

  void releaseSavepoint(Savepoint savepoint) throws SQLException {
    delegate.releaseSavepoint(savepoint)
  }

  Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
    return delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability)
  }

  PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
    return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability)
  }

  CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
    return delegate.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability)
  }

  PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
    return delegate.prepareStatement(sql, autoGeneratedKeys)
  }

  PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
    return delegate.prepareStatement(sql, columnIndexes)
  }

  PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
    return delegate.prepareStatement(sql, columnNames)
  }

  Clob createClob() throws SQLException {
    return delegate.createClob()
  }

  Blob createBlob() throws SQLException {
    return delegate.createBlob()
  }

  NClob createNClob() throws SQLException {
    return delegate.createNClob()
  }

  SQLXML createSQLXML() throws SQLException {
    return delegate.createSQLXML()
  }

  boolean isValid(int timeout) throws SQLException {
    return delegate.isValid(timeout)
  }

  void setClientInfo(String name, String value) throws SQLClientInfoException {
    delegate.setClientInfo(name, value)
  }

  void setClientInfo(Properties properties) throws SQLClientInfoException {
    delegate.setClientInfo(properties)
  }

  String getClientInfo(String name) throws SQLException {
    return delegate.getClientInfo(name)
  }

  Properties getClientInfo() throws SQLException {
    return delegate.getClientInfo()
  }

  Array createArrayOf(String typeName, Object[] elements) throws SQLException {
    return delegate.createArrayOf(typeName, elements)
  }

  Struct createStruct(String typeName, Object[] attributes) throws SQLException {
    return delegate.createStruct(typeName, attributes)
  }

  void setSchema(String schema) throws SQLException {
    delegate.setSchema(schema)
  }

  String getSchema() throws SQLException {
    return delegate.getSchema()
  }

  void abort(Executor executor) throws SQLException {
    delegate.abort(executor)
  }

  void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
    delegate.setNetworkTimeout(executor, milliseconds)
  }

  int getNetworkTimeout() throws SQLException {
    return delegate.getNetworkTimeout()
  }
}
