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