-
Notifications
You must be signed in to change notification settings - Fork 624
Expand file tree
/
Copy pathConnectionImpl.java
More file actions
664 lines (574 loc) · 24.7 KB
/
Copy pathConnectionImpl.java
File metadata and controls
664 lines (574 loc) · 24.7 KB
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
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
package com.clickhouse.jdbc;
import com.clickhouse.client.api.Client;
import com.clickhouse.client.api.ClientConfigProperties;
import com.clickhouse.client.api.metadata.TableSchema;
import com.clickhouse.client.api.query.GenericRecord;
import com.clickhouse.client.api.query.QuerySettings;
import com.clickhouse.data.ClickHouseColumn;
import com.clickhouse.data.ClickHouseDataType;
import com.clickhouse.jdbc.internal.ExceptionUtils;
import com.clickhouse.jdbc.internal.FeatureManager;
import com.clickhouse.jdbc.internal.JdbcConfiguration;
import com.clickhouse.jdbc.internal.ParsedPreparedStatement;
import com.clickhouse.jdbc.internal.SqlParserFacade;
import com.clickhouse.jdbc.metadata.DatabaseMetaDataImpl;
import com.google.common.collect.ImmutableMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Calendar;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.Executor;
public class ConnectionImpl implements Connection, JdbcV2Wrapper {
private static final Logger LOG = LoggerFactory.getLogger(ConnectionImpl.class);
protected final String url;
private final Client client; // this member is private to force using getClient()
protected final JdbcConfiguration config;
private boolean closed = false;
protected final boolean onCluster;
protected final String cluster;
private String catalog;
private String schema;
private String appName;
private QuerySettings defaultQuerySettings;
private boolean readOnly;
private int holdability;
private final DatabaseMetaDataImpl metadata;
protected final Calendar defaultCalendar;
private final SqlParserFacade sqlParser;
private Executor networkTimeoutExecutor;
private final FeatureManager featureManager;
private volatile ImmutableMap<String, Class<?>> typeMap;
public ConnectionImpl(String url, Properties info) throws SQLException {
try {
this.url = url;//Raw URL
this.config = new JdbcConfiguration(url, info);
final String tmpClusterName = config.getDriverProperty(DriverProperties.CLUSTER_NAME.getKey(), DriverProperties.CLUSTER_NAME.getDefaultValue());
this.cluster = tmpClusterName == null ? null : tmpClusterName.trim();
this.onCluster = this.cluster != null && !this.cluster.isEmpty();
this.appName = "";
this.readOnly = false;
this.holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
String clientName = Driver.DRIVER_CLIENT_NAME + Driver.getLibraryVersion();
Map<String, String> clientProperties = config.getClientProperties();
if (clientProperties.get(ClientConfigProperties.CLIENT_NAME.getKey()) != null) {
this.appName = clientProperties.get(ClientConfigProperties.CLIENT_NAME.getKey()).trim();
clientName = this.appName + " " + clientName; // Use the application name as client name
} else if (clientProperties.get(ClientConfigProperties.PRODUCT_NAME.getKey()) != null) {
// Backward compatibility for old property
this.appName = clientProperties.get(ClientConfigProperties.PRODUCT_NAME.getKey()).trim();
clientName = this.appName + " " + clientName; // Use the application name as client name
}
if (this.config.isDisableFrameworkDetection()) {
LOG.debug("Framework detection is disabled.");
} else {
String detectedFrameworks = Driver.FrameworksDetection.getFrameworksDetected();
LOG.debug("Detected frameworks: {}", detectedFrameworks);
if (!detectedFrameworks.trim().isEmpty()) {
clientName += " (" + detectedFrameworks + ")";
}
}
this.client = this.config.applyClientProperties(new Client.Builder())
.setClientName(clientName)
.build();
String serverTimezone = this.client.getServerTimeZone();
if (serverTimezone == null) {
// we cannot operate without timezone
this.client.loadServerInfo();
}
this.schema = client.getDefaultDatabase();
this.defaultQuerySettings = new QuerySettings();
this.metadata = new DatabaseMetaDataImpl(this, false, url);
this.defaultCalendar = Calendar.getInstance();
this.sqlParser = SqlParserFacade.getParser(config.getDriverProperty(DriverProperties.SQL_PARSER.getKey(),
DriverProperties.SQL_PARSER.getDefaultValue()), config);
this.featureManager = new FeatureManager(this.config);
this.typeMap = ImmutableMap.<String, Class<?>>builder().putAll(this.config.getTypeMap()).buildKeepingLast();
} catch (SQLException e) {
throw e;
} catch (Exception e) {
throw new SQLException("Failed to create connection", ExceptionUtils.SQL_STATE_CONNECTION_EXCEPTION, e);
}
}
public SqlParserFacade getSqlParser() {
return sqlParser;
}
public QuerySettings getDefaultQuerySettings() {
return defaultQuerySettings;
}
public void setDefaultQuerySettings(QuerySettings settings) {
this.defaultQuerySettings = settings;
}
public Calendar getDefaultCalendar() {
return defaultCalendar;
}
public String getServerVersion() throws SQLException {
GenericRecord result = client.queryAll("SELECT version() as server_version").stream()
.findFirst().orElseThrow(() -> new SQLException("Failed to retrieve server version.", ExceptionUtils.SQL_STATE_CLIENT_ERROR));
return result.getString("server_version");
}
/**
* Returns configuration for current connection. Changes made to the instance of configuration may have side effects.
* Application should avoid making changes to this object until it is documented.
* @return - reference to internal instance of JdbcConfiguration
*/
public JdbcConfiguration getJdbcConfig() {
return this.config;
}
@Override
public Statement createStatement() throws SQLException {
ensureOpen();
return createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);
}
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException {
ensureOpen();
return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);
}
@Override
public CallableStatement prepareCall(String sql) throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("prepareCall(String sql)");
return null;
}
@Override
public String nativeSQL(String sql) throws SQLException {
ensureOpen();
// Currently it replaces escaped functions with real ones.
return StatementImpl.escapedSQLToNative(sql);
}
@Override
public void setAutoCommit(boolean autoCommit) throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("setAutoCommit(false)", !autoCommit);
}
@Override
public boolean getAutoCommit() throws SQLException {
ensureOpen();
return true;
}
@Override
public void commit() throws SQLException {
featureManager.unsupportedFeatureThrow("commit()");
}
@Override
public void rollback() throws SQLException {
featureManager.unsupportedFeatureThrow("rollback()");
}
@Override
public void close() throws SQLException {
if (isClosed()) {
return;
}
closed = true; // mark as closed to prevent further invocations
client.close(); // this will disrupt pending requests.
}
@Override
public boolean isClosed() throws SQLException {
return closed;
}
@Override
public DatabaseMetaData getMetaData() throws SQLException {
ensureOpen();
return this.metadata;
}
@Override
public void setReadOnly(boolean readOnly) throws SQLException {
ensureOpen();
// This method is just a hint for the driver. Documentation doesn't tell to block update operations.
// Currently, we do not use this hint but some connection pools may use this property.
// So we just save and return
this.readOnly = readOnly;
}
@Override
public boolean isReadOnly() throws SQLException {
ensureOpen();
return readOnly;
}
@Override
public void setCatalog(String catalog) throws SQLException {
ensureOpen();
// this.catalog = catalog; currently not supported
}
@Override
public String getCatalog() throws SQLException {
return catalog;
}
@Override
public void setTransactionIsolation(int level) throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("setTransactionIsolation(TRANSACTION_NONE)", TRANSACTION_NONE != level);
}
@Override
public int getTransactionIsolation() throws SQLException {
ensureOpen();
return TRANSACTION_NONE;
}
@Override
public SQLWarning getWarnings() throws SQLException {
ensureOpen();
return null;
}
@Override
public void clearWarnings() throws SQLException {
ensureOpen();
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
ensureOpen();
return createStatement(resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
ensureOpen();
return prepareStatement(sql, resultSetType, resultSetConcurrency, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("prepareCall(String sql, int resultSetType, int resultSetConcurrency)");
return null;
}
@Override
public Map<String, Class<?>> getTypeMap() throws SQLException {
ensureOpen();
return this.typeMap;
}
@Override
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
ensureOpen();
if (map == null) {
throw new SQLException("Type map cannot be null", ExceptionUtils.SQL_STATE_CLIENT_ERROR);
}
this.typeMap = ImmutableMap.<String, Class<?>>builder().putAll(map).buildKeepingLast();
}
@Override
public void setHoldability(int holdability) throws SQLException {
ensureOpen();
if (holdability != ResultSet.HOLD_CURSORS_OVER_COMMIT && holdability != ResultSet.CLOSE_CURSORS_AT_COMMIT) {
throw new SQLException("Only ResultSet.HOLD_CURSORS_OVER_COMMIT and ResultSet.CLOSE_CURSORS_AT_COMMIT allowed for holdability");
}
// we do not support transactions and almost always use auto-commit.
// holdability regulates is result set is open or closed on commit.
// currently we ignore value and always set what we support.
this.holdability = ResultSet.HOLD_CURSORS_OVER_COMMIT;
}
@Override
public int getHoldability() throws SQLException {
ensureOpen();
return holdability;
}
@Override
public Savepoint setSavepoint() throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("setSavepoint()");
return null;
}
@Override
public Savepoint setSavepoint(String name) throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("setSavepoint(String name)");
return null;
}
@Override
public void rollback(Savepoint savepoint) throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("rollback(Savepoint savepoint)");
}
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("releaseSavepoint(Savepoint savepoint)");
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
ensureOpen();
checkResultSetFlags(resultSetType, resultSetConcurrency, resultSetHoldability);
return new StatementImpl(this);
}
private void checkResultSetFlags(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
if (!config.isIgnoreUnsupportedRequests()) {
if (resultSetType != ResultSet.TYPE_FORWARD_ONLY) {
throw new SQLFeatureNotSupportedException("Cannot create statement with result set type other then ResultSet.TYPE_FORWARD_ONLY",
ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
if (resultSetConcurrency != ResultSet.CONCUR_READ_ONLY) {
throw new SQLFeatureNotSupportedException("Cannot create statement with result set concurrency other then ResultSet.CONCUR_READ_ONLY",
ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
}
}
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
ensureOpen();
checkResultSetFlags(resultSetType, resultSetConcurrency, resultSetHoldability);
ParsedPreparedStatement parsedStatement = sqlParser.parsePreparedStatement(sql);
if (parsedStatement.isInsert() && config.isBetaFeatureEnabled(DriverProperties.BETA_ROW_BINARY_WRITER)) {
/*
* RowBinary can be used when
* - INSERT INTO t (c1, c2) VALUES (?, ?)
* - INSERT INTO t VALUES (?, ?, ?)
* - number of arguments matches schema or column list
* RowBinary cannot be used when
* - INSERT INTO t VALUES (now(), ?, ?) !# there is a function in the values
* - INSERT INTO t VALUES (now(), ?, 1), (now(), ?, 2) !# multiple values list
* - INSERT INTO t SELECT ?, ?, ? !# insert from select
*/
if (!parsedStatement.isInsertWithSelect() && parsedStatement.getAssignValuesGroups() == 1
&& !parsedStatement.isUseFunction()) {
TableSchema tableSchema = client.getTableSchema(parsedStatement.getTable(), schema);
return new WriterStatementImpl(this, sql, tableSchema, parsedStatement);
}
}
return new PreparedStatementImpl(this, sql, parsedStatement);
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)");
return null;
}
@Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
ensureOpen();
//TODO: Should this be supported?
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, int autoGeneratedKeys) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
} else {
return prepareStatement(sql);
}
}
@Override
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
ensureOpen();
//TODO: Should this be supported?
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, int[] columnIndexes) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
} else {
return prepareStatement(sql);
}
}
@Override
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
ensureOpen();
//TODO: Should this be supported?
if (!config.isIgnoreUnsupportedRequests()) {
throw new SQLFeatureNotSupportedException("prepareStatement(String sql, String[] columnNames) not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
} else {
return prepareStatement(sql);
}
}
@Override
public Clob createClob() throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("createClob()");
return null;
}
@Override
public Blob createBlob() throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("createBlob()");
return null;
}
@Override
public NClob createNClob() throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("createNClob()");
return null;
}
@Override
public SQLXML createSQLXML() throws SQLException {
ensureOpen();
featureManager.unsupportedFeatureThrow("createSQLXML()");
return null;
}
@Override
public boolean isValid(int timeout) throws SQLException {
if (timeout < 0) {
throw new SQLException("Timeout must be >= 0", ExceptionUtils.SQL_STATE_CLIENT_ERROR);
}
if (isClosed()) {
return false;
}
return timeout == 0
? client.ping()
: client.ping(Duration.ofSeconds(timeout).toMillis());
}
@Override
public void setClientInfo(String name, String value) throws SQLClientInfoException {
if (ClientInfoProperties.APPLICATION_NAME.getKey().equals(name)) {
config.updateUserClient(value, client);
appName = value;
}
// TODO: generate warning for unknown properties
}
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
Set<String> toSet = new HashSet<>();
Set<String> toReset = new HashSet<>();
for (ClientInfoProperties p : ClientInfoProperties .values()) {
String key = p.getKey();
if (properties.containsKey(key)) {
toSet.add(key);
} else {
toReset.add(key);
}
}
// first we reset value
for (String key : toReset) {
setClientInfo(key, null);
}
// then we set value, so aliases will not clean values accidentally
for (String key : toSet) {
setClientInfo(key, properties.getProperty(key));
}
}
@Override
public String getClientInfo(String name) throws SQLException {
ensureOpen();
if (ClientInfoProperties.APPLICATION_NAME.getKey().equals(name)) {
return appName;
} else {
return null;
}
}
@Override
public Properties getClientInfo() throws SQLException {
ensureOpen();
Properties clientInfo = new Properties();
clientInfo.put(ClientInfoProperties.APPLICATION_NAME.getKey(), appName);
return clientInfo;
}
/**
* Creating multilevel arrays may be confusing.
* Spec doesn't tell much about it so there may be different variants.
* Note: createArrayOf() expect type name be for element of the array and for
* Array(Array(Int8)) it should be Int8 according to spec. However element type
* of 1st level array is Array(Int8)
* @param typeName the SQL name of the type the elements of the array map to. The typeName is a
* database-specific name which may be the name of a built-in type, a user-defined type or a standard SQL type supported by this database. This
* is the value returned by {@code Array.getBaseTypeName}
*
* @param elements the elements that populate the returned object
* @return
* @throws SQLException
*/
@Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
ensureOpen();
if (typeName == null) {
throw new SQLFeatureNotSupportedException("typeName cannot be null");
}
ClickHouseColumn column = ClickHouseColumn.of("array", typeName);
try {
return new com.clickhouse.jdbc.types.Array(column, elements);
} catch (Exception e) {
throw new SQLException("Failed to create array", ExceptionUtils.SQL_STATE_CLIENT_ERROR, e);
}
}
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
ensureOpen();
if (typeName == null) {
throw new SQLFeatureNotSupportedException("typeName cannot be null");
}
ClickHouseColumn column = ClickHouseColumn.of("v", typeName);
if (column.getDataType().equals(ClickHouseDataType.Tuple)) {
return new com.clickhouse.jdbc.types.Struct(column, attributes);
} else {
throw new SQLException("Only Tuple datatype is supported for Struct", ExceptionUtils.SQL_STATE_CLIENT_ERROR);
}
}
@Override
public void setSchema(String schema) throws SQLException {
ensureOpen();
this.schema = schema;
defaultQuerySettings.setDatabase(this.schema);
}
@Override
public String getSchema() throws SQLException {
ensureOpen();
return schema;
}
@Override
public void abort(Executor executor) throws SQLException {
if (executor == null) {
throw new SQLException("Executor must be not null");
}
// This method should check permissions with SecurityManager but the one is deprecated.
// There is no replacement for SecurityManger and it is marked for removal.
this.close();
}
@Override
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
ensureOpen();
// Very good mail thread about this method implementation. https://mail.openjdk.org/pipermail/jdbc-spec-discuss/2017-November/000236.html
// This method should check permissions with SecurityManager but the one is deprecated.
// There is no replacement for SecurityManger and it is marked for removal.
if (milliseconds > 0 && executor == null) {
// we need executor only for positive timeout values.
throw new SQLException("Executor must be not null");
}
if (milliseconds < 0) {
throw new SQLException("Timeout must be >= 0");
}
// How it should work:
// if timeout is set with this method then any timeout exception should be reported to the connection
// when connection get signal about timeout it uses executor to abort itself
// Some connection pools set timeout before calling Connection#close() to ensure that this operation will not hang
// Socket timeout is propagated with QuerySettings this connection has.
networkTimeoutExecutor = executor;
defaultQuerySettings.setNetworkTimeout(milliseconds, ChronoUnit.MILLIS);
}
// Should be called by child object to notify about timeout.
public synchronized void onNetworkTimeout() {
if (this.closed || networkTimeoutExecutor == null) {
return; // we closed already or have not set network timeout so do nothing.
}
networkTimeoutExecutor.execute(() -> {
try {
this.abort(networkTimeoutExecutor);
} catch (SQLException e) {
throw new RuntimeException("Failed to abort connection", e);
}
});
}
@Override
public int getNetworkTimeout() throws SQLException {
return defaultQuerySettings.getNetworkTimeout().intValue();
}
/**
* Returns instance of the client used to execute queries by this connection.
* @return - client instance
*/
public Client getClient() throws SQLException {
ensureOpen();
return client;
}
private void ensureOpen() throws SQLException {
if (isClosed()) {
throw new SQLException("Connection is closed", ExceptionUtils.SQL_STATE_CONNECTION_EXCEPTION);
}
}
}