001package org.avaje.datasource.delegate; 002 003import java.sql.*; 004import java.util.Map; 005import java.util.Properties; 006import java.util.concurrent.Executor; 007 008public class ConnectionDelegator implements Connection { 009 010 private final Connection delegate; 011 012 protected String currentSchema; 013 014 public ConnectionDelegator(Connection delegate) { 015 this.delegate = delegate; 016 } 017 018 /** 019 * Return the underlying connection. 020 */ 021 public Connection getDelegate() { 022 return delegate; 023 } 024 025 @Override 026 public void setSchema(String schema) throws SQLException { 027 delegate.setSchema(schema); 028 currentSchema = schema; 029 } 030 031 @Override 032 public String getSchema() throws SQLException { 033 return delegate.getSchema(); 034 } 035 036 @Override 037 public void abort(Executor executor) throws SQLException { 038 delegate.abort(executor); 039 } 040 041 @Override 042 public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { 043 delegate.setNetworkTimeout(executor, milliseconds); 044 } 045 046 @Override 047 public int getNetworkTimeout() throws SQLException { 048 return delegate.getNetworkTimeout(); 049 } 050 051 public Statement createStatement() throws SQLException { 052 return delegate.createStatement(); 053 } 054 055 public PreparedStatement prepareStatement(String sql) throws SQLException { 056 return delegate.prepareStatement(sql); 057 } 058 059 public CallableStatement prepareCall(String sql) throws SQLException { 060 return delegate.prepareCall(sql); 061 } 062 063 public String nativeSQL(String sql) throws SQLException { 064 return delegate.nativeSQL(sql); 065 } 066 067 public void setAutoCommit(boolean autoCommit) throws SQLException { 068 delegate.setAutoCommit(autoCommit); 069 } 070 071 public boolean getAutoCommit() throws SQLException { 072 return delegate.getAutoCommit(); 073 } 074 075 public void commit() throws SQLException { 076 delegate.commit(); 077 } 078 079 public void rollback() throws SQLException { 080 delegate.rollback(); 081 } 082 083 public void close() throws SQLException { 084 delegate.close(); 085 } 086 087 public boolean isClosed() throws SQLException { 088 return delegate.isClosed(); 089 } 090 091 public DatabaseMetaData getMetaData() throws SQLException { 092 return delegate.getMetaData(); 093 } 094 095 public void setReadOnly(boolean readOnly) throws SQLException { 096 delegate.setReadOnly(readOnly); 097 } 098 099 public boolean isReadOnly() throws SQLException { 100 return delegate.isReadOnly(); 101 } 102 103 public void setCatalog(String catalog) throws SQLException { 104 delegate.setCatalog(catalog); 105 } 106 107 public String getCatalog() throws SQLException { 108 return delegate.getCatalog(); 109 } 110 111 public void setTransactionIsolation(int level) throws SQLException { 112 delegate.setTransactionIsolation(level); 113 } 114 115 public int getTransactionIsolation() throws SQLException { 116 return delegate.getTransactionIsolation(); 117 } 118 119 public SQLWarning getWarnings() throws SQLException { 120 return delegate.getWarnings(); 121 } 122 123 public void clearWarnings() throws SQLException { 124 delegate.clearWarnings(); 125 } 126 127 public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException { 128 return delegate.createStatement(resultSetType, resultSetConcurrency); 129 } 130 131 public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) 132 throws SQLException { 133 return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency); 134 } 135 136 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) 137 throws SQLException { 138 return delegate.prepareCall(sql, resultSetType, resultSetConcurrency); 139 } 140 141 public Map<String, Class<?>> getTypeMap() throws SQLException { 142 return delegate.getTypeMap(); 143 } 144 145 public void setTypeMap(Map<String, Class<?>> map) throws SQLException { 146 delegate.setTypeMap(map); 147 } 148 149 public void setHoldability(int holdability) throws SQLException { 150 delegate.setHoldability(holdability); 151 } 152 153 public int getHoldability() throws SQLException { 154 return delegate.getHoldability(); 155 } 156 157 public Savepoint setSavepoint() throws SQLException { 158 return delegate.setSavepoint(); 159 } 160 161 public Savepoint setSavepoint(String name) throws SQLException { 162 return delegate.setSavepoint(name); 163 } 164 165 public void rollback(Savepoint savepoint) throws SQLException { 166 delegate.rollback(savepoint); 167 } 168 169 public void releaseSavepoint(Savepoint savepoint) throws SQLException { 170 delegate.releaseSavepoint(savepoint); 171 } 172 173 public Statement createStatement(int resultSetType, int resultSetConcurrency, 174 int resultSetHoldability) throws SQLException { 175 return delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); 176 } 177 178 public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { 179 return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); 180 } 181 182 public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, 183 int resultSetHoldability) throws SQLException { 184 return delegate.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); 185 } 186 187 public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { 188 return delegate.prepareStatement(sql, autoGeneratedKeys); 189 } 190 191 public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { 192 return delegate.prepareStatement(sql, columnIndexes); 193 } 194 195 public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { 196 return delegate.prepareStatement(sql, columnNames); 197 } 198 199 public Clob createClob() throws SQLException { 200 return delegate.createClob(); 201 } 202 203 public Blob createBlob() throws SQLException { 204 return delegate.createBlob(); 205 } 206 207 public NClob createNClob() throws SQLException { 208 return delegate.createNClob(); 209 } 210 211 public SQLXML createSQLXML() throws SQLException { 212 return delegate.createSQLXML(); 213 } 214 215 public boolean isValid(int timeout) throws SQLException { 216 return delegate.isValid(timeout); 217 } 218 219 public void setClientInfo(String name, String value) throws SQLClientInfoException { 220 delegate.setClientInfo(name, value); 221 } 222 223 public void setClientInfo(Properties properties) throws SQLClientInfoException { 224 delegate.setClientInfo(properties); 225 } 226 227 public String getClientInfo(String name) throws SQLException { 228 return delegate.getClientInfo(name); 229 } 230 231 public Properties getClientInfo() throws SQLException { 232 return delegate.getClientInfo(); 233 } 234 235 public Array createArrayOf(String typeName, Object[] elements) throws SQLException { 236 return delegate.createArrayOf(typeName, elements); 237 } 238 239 public Struct createStruct(String typeName, Object[] attributes) throws SQLException { 240 return delegate.createStruct(typeName, attributes); 241 } 242 243 public <T> T unwrap(Class<T> iface) throws SQLException { 244 if (iface.equals(java.sql.Connection.class)) { 245 return (T)delegate; 246 } 247 return delegate.unwrap(iface); 248 } 249 250 public boolean isWrapperFor(Class<?> iface) throws SQLException { 251 return delegate.isWrapperFor(iface); 252 } 253}