|
| 1 | +/* Copyright (c) 2015 |
| 2 | + * by Charles River Development, Inc., Burlington, MA |
| 3 | + * |
| 4 | + * This software is furnished under a license and may be used only in |
| 5 | + * accordance with the terms of such license. This software may not be |
| 6 | + * provided or otherwise made available to any other party. No title to |
| 7 | + * nor ownership of the software is hereby transferred. |
| 8 | + * |
| 9 | + * This software is the intellectual property of Charles River Development, Inc., |
| 10 | + * and is protected by the copyright laws of the United States of America. |
| 11 | + * All rights reserved internationally. |
| 12 | + * |
| 13 | + */ |
| 14 | + |
| 15 | +package com.crd.data.wrapper; |
| 16 | + |
| 17 | +import java.sql.Array; |
| 18 | +import java.sql.Blob; |
| 19 | +import java.sql.CallableStatement; |
| 20 | +import java.sql.Clob; |
| 21 | +import java.sql.Connection; |
| 22 | +import java.sql.DatabaseMetaData; |
| 23 | +import java.sql.NClob; |
| 24 | +import java.sql.PreparedStatement; |
| 25 | +import java.sql.SQLClientInfoException; |
| 26 | +import java.sql.SQLException; |
| 27 | +import java.sql.SQLWarning; |
| 28 | +import java.sql.SQLXML; |
| 29 | +import java.sql.Savepoint; |
| 30 | +import java.sql.Statement; |
| 31 | +import java.sql.Struct; |
| 32 | +import java.util.Map; |
| 33 | +import java.util.Properties; |
| 34 | +import java.util.concurrent.Executor; |
| 35 | + |
| 36 | +/** |
| 37 | + * Default wrapper around the Connection |
| 38 | + * @author yshao |
| 39 | + * |
| 40 | + */ |
| 41 | +public class ConnectionWrapper implements Connection { |
| 42 | + |
| 43 | + private final Connection conn; |
| 44 | + |
| 45 | + public ConnectionWrapper(Connection conn) { |
| 46 | + this.conn = conn; |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public <T> T unwrap(Class<T> iface) throws SQLException { |
| 51 | + if (isWrapperFor(iface)) { |
| 52 | + return (T)conn; |
| 53 | + } |
| 54 | + throw new SQLException("This is not a wrapper of a Connection"); |
| 55 | + } |
| 56 | + |
| 57 | + @Override |
| 58 | + public boolean isWrapperFor(Class<?> iface) throws SQLException { |
| 59 | + return conn.isWrapperFor(iface); |
| 60 | + } |
| 61 | + |
| 62 | + @Override |
| 63 | + public Statement createStatement() throws SQLException { |
| 64 | + return conn.createStatement(); |
| 65 | + } |
| 66 | + |
| 67 | + @Override |
| 68 | + public PreparedStatement prepareStatement(String sql) throws SQLException { |
| 69 | + return conn.prepareStatement(sql); |
| 70 | + } |
| 71 | + |
| 72 | + @Override |
| 73 | + public CallableStatement prepareCall(String sql) throws SQLException { |
| 74 | + return conn.prepareCall(sql); |
| 75 | + } |
| 76 | + |
| 77 | + @Override |
| 78 | + public String nativeSQL(String sql) throws SQLException { |
| 79 | + return conn.nativeSQL(sql); |
| 80 | + } |
| 81 | + |
| 82 | + @Override |
| 83 | + public void setAutoCommit(boolean autoCommit) throws SQLException { |
| 84 | + conn.setAutoCommit(autoCommit); |
| 85 | + } |
| 86 | + |
| 87 | + @Override |
| 88 | + public boolean getAutoCommit() throws SQLException { |
| 89 | + return conn.getAutoCommit(); |
| 90 | + } |
| 91 | + |
| 92 | + @Override |
| 93 | + public void commit() throws SQLException { |
| 94 | + conn.commit(); |
| 95 | + } |
| 96 | + |
| 97 | + @Override |
| 98 | + public void rollback() throws SQLException { |
| 99 | + conn.rollback(); |
| 100 | + } |
| 101 | + |
| 102 | + @Override |
| 103 | + public void close() throws SQLException { |
| 104 | + conn.close(); |
| 105 | + } |
| 106 | + |
| 107 | + @Override |
| 108 | + public boolean isClosed() throws SQLException { |
| 109 | + return conn.isClosed(); |
| 110 | + } |
| 111 | + |
| 112 | + @Override |
| 113 | + public DatabaseMetaData getMetaData() throws SQLException { |
| 114 | + return conn.getMetaData(); |
| 115 | + } |
| 116 | + |
| 117 | + @Override |
| 118 | + public void setReadOnly(boolean readOnly) throws SQLException { |
| 119 | + conn.setReadOnly(readOnly); |
| 120 | + } |
| 121 | + |
| 122 | + @Override |
| 123 | + public boolean isReadOnly() throws SQLException { |
| 124 | + return conn.isReadOnly(); |
| 125 | + } |
| 126 | + |
| 127 | + @Override |
| 128 | + public void setCatalog(String catalog) throws SQLException { |
| 129 | + conn.setCatalog(catalog); |
| 130 | + } |
| 131 | + |
| 132 | + @Override |
| 133 | + public String getCatalog() throws SQLException { |
| 134 | + return conn.getCatalog(); |
| 135 | + } |
| 136 | + |
| 137 | + @Override |
| 138 | + public void setTransactionIsolation(int level) throws SQLException { |
| 139 | + conn.setTransactionIsolation(level); |
| 140 | + } |
| 141 | + |
| 142 | + @Override |
| 143 | + public int getTransactionIsolation() throws SQLException { |
| 144 | + return conn.getTransactionIsolation(); |
| 145 | + } |
| 146 | + |
| 147 | + @Override |
| 148 | + public SQLWarning getWarnings() throws SQLException { |
| 149 | + return conn.getWarnings(); |
| 150 | + } |
| 151 | + |
| 152 | + @Override |
| 153 | + public void clearWarnings() throws SQLException { |
| 154 | + conn.clearWarnings(); |
| 155 | + } |
| 156 | + |
| 157 | + @Override |
| 158 | + public Statement createStatement(int resultSetType, int resultSetConcurrency) |
| 159 | + throws SQLException { |
| 160 | + return conn.createStatement(resultSetType, resultSetConcurrency); |
| 161 | + } |
| 162 | + |
| 163 | + @Override |
| 164 | + public PreparedStatement prepareStatement(String sql, int resultSetType, |
| 165 | + int resultSetConcurrency) throws SQLException { |
| 166 | + return conn.prepareStatement(sql, resultSetType, resultSetConcurrency); |
| 167 | + } |
| 168 | + |
| 169 | + @Override |
| 170 | + public CallableStatement prepareCall(String sql, int resultSetType, |
| 171 | + int resultSetConcurrency) throws SQLException { |
| 172 | + return conn.prepareCall(sql, resultSetType, resultSetConcurrency); |
| 173 | + } |
| 174 | + |
| 175 | + @Override |
| 176 | + public Map<String, Class<?>> getTypeMap() throws SQLException { |
| 177 | + return conn.getTypeMap(); |
| 178 | + } |
| 179 | + |
| 180 | + @Override |
| 181 | + public void setTypeMap(Map<String, Class<?>> map) throws SQLException { |
| 182 | + conn.setTypeMap(map); |
| 183 | + } |
| 184 | + |
| 185 | + @Override |
| 186 | + public void setHoldability(int holdability) throws SQLException { |
| 187 | + conn.setHoldability(holdability); |
| 188 | + } |
| 189 | + |
| 190 | + @Override |
| 191 | + public int getHoldability() throws SQLException { |
| 192 | + return conn.getHoldability(); |
| 193 | + } |
| 194 | + |
| 195 | + @Override |
| 196 | + public Savepoint setSavepoint() throws SQLException { |
| 197 | + return conn.setSavepoint(); |
| 198 | + } |
| 199 | + |
| 200 | + @Override |
| 201 | + public Savepoint setSavepoint(String name) throws SQLException { |
| 202 | + return conn.setSavepoint(name); |
| 203 | + } |
| 204 | + |
| 205 | + @Override |
| 206 | + public void rollback(Savepoint savepoint) throws SQLException { |
| 207 | + conn.rollback(savepoint); |
| 208 | + } |
| 209 | + |
| 210 | + @Override |
| 211 | + public void releaseSavepoint(Savepoint savepoint) throws SQLException { |
| 212 | + conn.releaseSavepoint(savepoint); |
| 213 | + } |
| 214 | + |
| 215 | + @Override |
| 216 | + public Statement createStatement(int resultSetType, |
| 217 | + int resultSetConcurrency, int resultSetHoldability) throws SQLException { |
| 218 | + return conn.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability); |
| 219 | + } |
| 220 | + |
| 221 | + @Override |
| 222 | + public PreparedStatement prepareStatement(String sql, int resultSetType, |
| 223 | + int resultSetConcurrency, int resultSetHoldability) throws SQLException { |
| 224 | + return conn.prepareStatement(sql, resultSetType, resultSetConcurrency, resultSetHoldability); |
| 225 | + } |
| 226 | + |
| 227 | + @Override |
| 228 | + public CallableStatement prepareCall(String sql, int resultSetType, |
| 229 | + int resultSetConcurrency, int resultSetHoldability) throws SQLException { |
| 230 | + return conn.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability); |
| 231 | + } |
| 232 | + |
| 233 | + @Override |
| 234 | + public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException { |
| 235 | + return conn.prepareStatement(sql, autoGeneratedKeys); |
| 236 | + } |
| 237 | + |
| 238 | + @Override |
| 239 | + public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException { |
| 240 | + return conn.prepareStatement(sql, columnIndexes); |
| 241 | + } |
| 242 | + |
| 243 | + @Override |
| 244 | + public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException { |
| 245 | + return conn.prepareStatement(sql, columnNames); |
| 246 | + } |
| 247 | + |
| 248 | + @Override |
| 249 | + public Clob createClob() throws SQLException { |
| 250 | + return conn.createClob(); |
| 251 | + } |
| 252 | + |
| 253 | + @Override |
| 254 | + public Blob createBlob() throws SQLException { |
| 255 | + return conn.createBlob(); |
| 256 | + } |
| 257 | + |
| 258 | + @Override |
| 259 | + public NClob createNClob() throws SQLException { |
| 260 | + return conn.createNClob(); |
| 261 | + } |
| 262 | + |
| 263 | + @Override |
| 264 | + public SQLXML createSQLXML() throws SQLException { |
| 265 | + return conn.createSQLXML(); |
| 266 | + } |
| 267 | + |
| 268 | + @Override |
| 269 | + public boolean isValid(int timeout) throws SQLException { |
| 270 | + return conn.isValid(timeout); |
| 271 | + } |
| 272 | + |
| 273 | + @Override |
| 274 | + public void setClientInfo(String name, String value) throws SQLClientInfoException { |
| 275 | + conn.setClientInfo(name, value); |
| 276 | + } |
| 277 | + |
| 278 | + @Override |
| 279 | + public void setClientInfo(Properties properties) throws SQLClientInfoException { |
| 280 | + conn.setClientInfo(properties); |
| 281 | + } |
| 282 | + |
| 283 | + @Override |
| 284 | + public String getClientInfo(String name) throws SQLException { |
| 285 | + return conn.getClientInfo(name); |
| 286 | + } |
| 287 | + |
| 288 | + @Override |
| 289 | + public Properties getClientInfo() throws SQLException { |
| 290 | + return conn.getClientInfo(); |
| 291 | + } |
| 292 | + |
| 293 | + @Override |
| 294 | + public Array createArrayOf(String typeName, Object[] elements) throws SQLException { |
| 295 | + return conn.createArrayOf(typeName, elements); |
| 296 | + } |
| 297 | + |
| 298 | + @Override |
| 299 | + public Struct createStruct(String typeName, Object[] attributes) throws SQLException { |
| 300 | + return conn.createStruct(typeName, attributes); |
| 301 | + } |
| 302 | + |
| 303 | + @Override |
| 304 | + public void setSchema(String schema) throws SQLException { |
| 305 | + conn.setSchema(schema); |
| 306 | + } |
| 307 | + |
| 308 | + @Override |
| 309 | + public String getSchema() throws SQLException { |
| 310 | + return conn.getSchema(); |
| 311 | + } |
| 312 | + |
| 313 | + @Override |
| 314 | + public void abort(Executor executor) throws SQLException { |
| 315 | + conn.abort(executor); |
| 316 | + } |
| 317 | + |
| 318 | + @Override |
| 319 | + public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException { |
| 320 | + conn.setNetworkTimeout(executor, milliseconds); |
| 321 | + } |
| 322 | + |
| 323 | + @Override |
| 324 | + public int getNetworkTimeout() throws SQLException { |
| 325 | + return conn.getNetworkTimeout(); |
| 326 | + } |
| 327 | +} |
0 commit comments