1   package com.atlassian.config.db;
2   
3   import java.sql.Array;
4   import java.sql.Blob;
5   import java.sql.CallableStatement;
6   import java.sql.Clob;
7   import java.sql.Connection;
8   import java.sql.DatabaseMetaData;
9   import java.sql.NClob;
10  import java.sql.PreparedStatement;
11  import java.sql.SQLClientInfoException;
12  import java.sql.SQLException;
13  import java.sql.SQLWarning;
14  import java.sql.SQLXML;
15  import java.sql.Savepoint;
16  import java.sql.Statement;
17  import java.sql.Struct;
18  import java.util.Map;
19  import java.util.Properties;
20  import java.util.concurrent.Executor;
21  
22  /**
23  * Connection implementation that delegates all calls to another Connection, allowing for easy overrides of methods.
24  */
25  public abstract class DelegatingConnection implements Connection
26  {
27      private final Connection delegate;
28      public DelegatingConnection(Connection delegate)
29      {
30          this.delegate = delegate;
31      }
32  
33      public Statement createStatement() throws SQLException
34      {
35          return delegate.createStatement();
36      }
37  
38      public PreparedStatement prepareStatement(String sql) throws SQLException
39      {
40          return delegate.prepareStatement(sql);
41      }
42  
43      public CallableStatement prepareCall(String sql) throws SQLException
44      {
45          return delegate.prepareCall(sql);
46      }
47  
48      public String nativeSQL(String sql) throws SQLException
49      {
50          return delegate.nativeSQL(sql);
51      }
52  
53      public void setAutoCommit(boolean autoCommit) throws SQLException
54      {
55          delegate.setAutoCommit(autoCommit);
56      }
57  
58      public boolean getAutoCommit() throws SQLException
59      {
60          return delegate.getAutoCommit();
61      }
62  
63      public void commit() throws SQLException
64      {
65          delegate.commit();
66      }
67  
68      public void rollback() throws SQLException
69      {
70          delegate.rollback();
71      }
72  
73      public void close() throws SQLException
74      {
75          delegate.close();
76      }
77  
78      public boolean isClosed() throws SQLException
79      {
80          return delegate.isClosed();
81      }
82  
83      public DatabaseMetaData getMetaData() throws SQLException
84      {
85          return delegate.getMetaData();
86      }
87  
88      public void setReadOnly(boolean readOnly) throws SQLException
89      {
90          delegate.setReadOnly(readOnly);
91      }
92  
93      public boolean isReadOnly() throws SQLException
94      {
95          return delegate.isReadOnly();
96      }
97  
98      public void setCatalog(String catalog) throws SQLException
99      {
100         delegate.setCatalog(catalog);
101     }
102 
103     public String getCatalog() throws SQLException
104     {
105         return delegate.getCatalog();
106     }
107 
108     public void setTransactionIsolation(int level) throws SQLException
109     {
110         delegate.setTransactionIsolation(level);
111     }
112 
113     public int getTransactionIsolation() throws SQLException
114     {
115         return delegate.getTransactionIsolation();
116     }
117 
118     public SQLWarning getWarnings() throws SQLException
119     {
120         return delegate.getWarnings();
121     }
122 
123     public void clearWarnings() throws SQLException
124     {
125         delegate.clearWarnings();
126     }
127 
128     public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
129     {
130         return delegate.createStatement(resultSetType, resultSetConcurrency);
131     }
132 
133     public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
134         throws SQLException
135     {
136         return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency);
137     }
138 
139     public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency)
140         throws SQLException
141     {
142         return delegate.prepareCall(sql, resultSetType, resultSetConcurrency);
143     }
144 
145     public Map<String, Class<?>> getTypeMap() throws SQLException
146     {
147         return delegate.getTypeMap();
148     }
149 
150     public void setTypeMap(Map<String, Class<?>> map) throws SQLException
151     {
152         delegate.setTypeMap(map);
153     }
154 
155     public void setHoldability(int holdability) throws SQLException
156     {
157         delegate.setHoldability(holdability);
158     }
159 
160     public int getHoldability() throws SQLException
161     {
162         return delegate.getHoldability();
163     }
164 
165     public Savepoint setSavepoint() throws SQLException
166     {
167         return delegate.setSavepoint();
168     }
169 
170     public Savepoint setSavepoint(String name) throws SQLException
171     {
172         return delegate.setSavepoint(name);
173     }
174 
175     public void rollback(Savepoint savepoint) throws SQLException
176     {
177         delegate.rollback(savepoint);
178     }
179 
180     public void releaseSavepoint(Savepoint savepoint) throws SQLException
181     {
182         delegate.releaseSavepoint(savepoint);
183     }
184 
185     public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
186         throws SQLException
187     {
188         return delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
189     }
190 
191     public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
192                                               int resultSetHoldability) throws SQLException
193     {
194         return delegate.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
195     }
196 
197     public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency,
198                                          int resultSetHoldability) throws SQLException
199     {
200         return delegate.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
201     }
202 
203     public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
204     {
205         return delegate.prepareStatement(sql, autoGeneratedKeys);
206     }
207 
208     public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
209     {
210         return delegate.prepareStatement(sql, columnIndexes);
211     }
212 
213     public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
214     {
215         return delegate.prepareStatement(sql, columnNames);
216     }
217 
218     public Clob createClob() throws SQLException
219     {
220         return delegate.createClob();
221     }
222 
223     public Blob createBlob() throws SQLException
224     {
225         return delegate.createBlob();
226     }
227 
228     public NClob createNClob() throws SQLException
229     {
230         return delegate.createNClob();
231     }
232 
233     public SQLXML createSQLXML() throws SQLException
234     {
235         return delegate.createSQLXML();
236     }
237 
238     public boolean isValid(int timeout) throws SQLException
239     {
240         return delegate.isValid(timeout);
241     }
242 
243     public void setClientInfo(String name, String value) throws SQLClientInfoException
244     {
245         delegate.setClientInfo(name, value);
246     }
247 
248     public void setClientInfo(Properties properties) throws SQLClientInfoException
249     {
250         delegate.setClientInfo(properties);
251     }
252 
253     public String getClientInfo(String name) throws SQLException
254     {
255         return delegate.getClientInfo(name);
256     }
257 
258     public Properties getClientInfo() throws SQLException
259     {
260         return delegate.getClientInfo();
261     }
262 
263     public Array createArrayOf(String typeName, Object[] elements) throws SQLException
264     {
265         return delegate.createArrayOf(typeName, elements);
266     }
267 
268     public Struct createStruct(String typeName, Object[] attributes) throws SQLException
269     {
270         return delegate.createStruct(typeName, attributes);
271     }
272 
273     public <T> T unwrap(Class<T> iface) throws SQLException
274     {
275         return delegate.unwrap(iface);
276     }
277 
278     public boolean isWrapperFor(Class<?> iface) throws SQLException
279     {
280         return delegate.isWrapperFor(iface);
281     }
282 
283     public void setSchema(String schema) throws SQLException
284     {
285         delegate.setSchema(schema);
286     }
287 
288     public String getSchema() throws SQLException
289     {
290         return delegate.getSchema();
291     }
292 
293     public void abort(Executor executor) throws SQLException
294     {
295         delegate.abort(executor);
296     }
297 
298     public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException
299     {
300         delegate.setNetworkTimeout(executor, milliseconds);
301     }
302 
303     public int getNetworkTimeout() throws SQLException
304     {
305         return delegate.getNetworkTimeout();
306     }
307     
308 }