1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
|
/*
* Copyright 2006-2012 Amazon Technologies, Inc. or its affiliates.
* Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
* of Amazon Technologies, Inc. or its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.amazon.carbonado.repo.jdbc;
import java.sql.*;
import org.apache.commons.logging.Log;
/**
* Connection returned by LoggingDataSource.
*
* @author Brian S O'Neill
*/
class LoggingConnection implements Connection {
private final Log mLog;
private final Connection mCon;
LoggingConnection(Log log, Connection con) {
mLog = log;
mCon = con;
}
public Statement createStatement() throws SQLException {
return new LoggingStatement(mLog, this, mCon.createStatement());
}
public Statement createStatement(int resultSetType, int resultSetConcurrency)
throws SQLException
{
return new LoggingStatement
(mLog, this, mCon.createStatement(resultSetType, resultSetConcurrency));
}
public Statement createStatement(int resultSetType, int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
{
return new LoggingStatement(mLog, this,
mCon.createStatement(resultSetType, resultSetConcurrency,
resultSetHoldability));
}
public PreparedStatement prepareStatement(String sql) throws SQLException {
return new LoggingPreparedStatement
(mLog, this, mCon.prepareStatement(sql), sql);
}
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency)
throws SQLException
{
return new LoggingPreparedStatement
(mLog, this, mCon.prepareStatement(sql, resultSetType, resultSetConcurrency), sql);
}
public PreparedStatement prepareStatement(String sql, int resultSetType,
int resultSetConcurrency, int resultSetHoldability)
throws SQLException
{
return new LoggingPreparedStatement
(mLog, this, mCon.prepareStatement(sql, resultSetType,
resultSetConcurrency, resultSetHoldability), sql);
}
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys)
throws SQLException
{
return new LoggingPreparedStatement
(mLog, this, mCon.prepareStatement(sql, autoGeneratedKeys), sql);
}
public PreparedStatement prepareStatement(String sql, int columnIndexes[])
throws SQLException
{
return new LoggingPreparedStatement
(mLog, this, mCon.prepareStatement(sql, columnIndexes), sql);
}
public PreparedStatement prepareStatement(String sql, String columnNames[])
throws SQLException
{
return new LoggingPreparedStatement
(mLog, this, mCon.prepareStatement(sql, columnNames), sql);
}
public CallableStatement prepareCall(String sql) throws SQLException {
return new LoggingCallableStatement(mLog, this, mCon.prepareCall(sql), sql);
}
public CallableStatement prepareCall(String sql, int resultSetType,
int resultSetConcurrency)
throws SQLException
{
return new LoggingCallableStatement
(mLog, this, mCon.prepareCall(sql, resultSetType, resultSetConcurrency), sql);
}
public CallableStatement prepareCall(String sql, int resultSetType,
int resultSetConcurrency,
int resultSetHoldability)
throws SQLException
{
return new LoggingCallableStatement
(mLog, this, mCon.prepareCall(sql, resultSetType,
resultSetConcurrency, resultSetHoldability), sql);
}
public String nativeSQL(String sql) throws SQLException {
return mCon.nativeSQL(sql);
}
public void setAutoCommit(boolean autoCommit) throws SQLException {
mLog.debug("Connection.setAutoCommit(" + autoCommit + ')');
mCon.setAutoCommit(autoCommit);
}
public boolean getAutoCommit() throws SQLException {
return mCon.getAutoCommit();
}
public void commit() throws SQLException {
mLog.debug("Connection.commit()");
mCon.commit();
}
public void rollback() throws SQLException {
mLog.debug("Connection.rollback()");
mCon.rollback();
}
public void close() throws SQLException {
mLog.debug("Connection.close()");
mCon.close();
}
public boolean isClosed() throws SQLException {
return mCon.isClosed();
}
public DatabaseMetaData getMetaData() throws SQLException {
mLog.debug("Connection.getMetaData()");
return mCon.getMetaData();
}
public void setReadOnly(boolean readOnly) throws SQLException {
mCon.setReadOnly(readOnly);
}
public boolean isReadOnly() throws SQLException {
return mCon.isReadOnly();
}
public void setCatalog(String catalog) throws SQLException {
mCon.setCatalog(catalog);
}
public String getCatalog() throws SQLException {
return mCon.getCatalog();
}
public void setTransactionIsolation(int level) throws SQLException {
String levelStr;
switch (level) {
default:
levelStr = String.valueOf(level);
break;
case Connection.TRANSACTION_NONE:
levelStr = "TRANSACTION_NONE";
break;
case Connection.TRANSACTION_READ_UNCOMMITTED:
levelStr = "TRANSACTION_READ_UNCOMMITTED";
break;
case Connection.TRANSACTION_READ_COMMITTED:
levelStr = "TRANSACTION_READ_COMMITTED";
break;
case Connection.TRANSACTION_REPEATABLE_READ:
levelStr = "TRANSACTION_REPEATABLE_READ";
break;
case Connection.TRANSACTION_SERIALIZABLE:
levelStr = "TRANSACTION_SERIALIZABLE";
break;
}
mLog.debug("Connection.setTransactionIsolation(" + levelStr + ')');
mCon.setTransactionIsolation(level);
}
public int getTransactionIsolation() throws SQLException {
return mCon.getTransactionIsolation();
}
public SQLWarning getWarnings() throws SQLException {
return mCon.getWarnings();
}
public void clearWarnings() throws SQLException {
mCon.clearWarnings();
}
public java.util.Map<String,Class<?>> getTypeMap() throws SQLException {
return mCon.getTypeMap();
}
public void setTypeMap(java.util.Map<String,Class<?>> map) throws SQLException {
mCon.setTypeMap(map);
}
public void setHoldability(int holdability) throws SQLException {
mCon.setHoldability(holdability);
}
public int getHoldability() throws SQLException {
return mCon.getHoldability();
}
public Savepoint setSavepoint() throws SQLException {
mLog.debug("Connection.setSavepoint()");
return mCon.setSavepoint();
}
public Savepoint setSavepoint(String name) throws SQLException {
mLog.debug("Connection.setSavepoint(name)");
return mCon.setSavepoint(name);
}
public void rollback(Savepoint savepoint) throws SQLException {
mLog.debug("Connection.rollback(savepoint)");
mCon.rollback(savepoint);
}
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
mLog.debug("Connection.releaseSavepoint(savepoint)");
mCon.releaseSavepoint(savepoint);
}
/**
* @since 1.2
*/
public Clob createClob() throws SQLException {
return mCon.createClob();
}
/**
* @since 1.2
*/
public Blob createBlob() throws SQLException {
return mCon.createBlob();
}
/**
* @since 1.2
*/
public NClob createNClob() throws SQLException {
return mCon.createNClob();
}
/**
* @since 1.2
*/
public SQLXML createSQLXML() throws SQLException {
return mCon.createSQLXML();
}
/**
* @since 1.2
*/
public boolean isValid(int timeout) throws SQLException {
return mCon.isValid(timeout);
}
/**
* @since 1.2
*/
public void setClientInfo(String name, String value) throws SQLClientInfoException {
mCon.setClientInfo(name, value);
}
/**
* @since 1.2
*/
public void setClientInfo(java.util.Properties properties) throws SQLClientInfoException {
mCon.setClientInfo(properties);
}
/**
* @since 1.2
*/
public String getClientInfo(String name) throws SQLException {
return mCon.getClientInfo(name);
}
/**
* @since 1.2
*/
public java.util.Properties getClientInfo() throws SQLException {
return mCon.getClientInfo();
}
/**
* @since 1.2
*/
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
return mCon.createArrayOf(typeName, elements);
}
/**
* @since 1.2
*/
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
return mCon.createStruct(typeName, attributes);
}
/**
* @since 1.2
*/
public <T> T unwrap(Class<T> iface) throws SQLException {
throw new UnsupportedOperationException();
}
/**
* @since 1.2
*/
public boolean isWrapperFor(Class<?> iface) throws SQLException {
throw new UnsupportedOperationException();
}
public void setSchema(String schema) throws SQLException {
mCon.setSchema(schema);
}
public String getSchema() throws SQLException {
return mCon.getSchema();
}
public void abort(java.util.concurrent.Executor executor) throws SQLException {
mCon.abort(executor);
}
public void setNetworkTimeout(java.util.concurrent.Executor executor, int milliseconds)
throws SQLException
{
mCon.setNetworkTimeout(executor, milliseconds);
}
public int getNetworkTimeout() throws SQLException {
return mCon.getNetworkTimeout();
}
}
|