Skip to content

Commit 0e4ecfc

Browse files
author
Paultagoras
committed
No-op flags
1 parent 20babb5 commit 0e4ecfc

File tree

4 files changed

+498
-141
lines changed

4 files changed

+498
-141
lines changed

jdbc-v2/src/main/java/com/clickhouse/jdbc/ConnectionImpl.java

Lines changed: 79 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,22 @@ public PreparedStatement prepareStatement(String sql) throws SQLException {
118118
@Override
119119
public CallableStatement prepareCall(String sql) throws SQLException {
120120
checkOpen();
121-
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
121+
if (!config.isIgnoreUnsupportedRequests()) {
122+
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
123+
}
124+
125+
return null;
122126
}
123127

124128
@Override
125129
public String nativeSQL(String sql) throws SQLException {
126130
checkOpen();
127131
/// TODO: this is not implemented according to JDBC spec and may not be used.
128-
throw new SQLFeatureNotSupportedException("nativeSQL not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
132+
if (!config.isIgnoreUnsupportedRequests()) {
133+
throw new SQLFeatureNotSupportedException("nativeSQL not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
134+
}
135+
136+
return null;
129137
}
130138

131139
@Override
@@ -181,7 +189,7 @@ public DatabaseMetaData getMetaData() throws SQLException {
181189
@Override
182190
public void setReadOnly(boolean readOnly) throws SQLException {
183191
checkOpen();
184-
if (readOnly) {
192+
if (!config.isIgnoreUnsupportedRequests() && readOnly) {
185193
throw new SQLFeatureNotSupportedException("read-only=true unsupported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
186194
}
187195
}
@@ -206,7 +214,7 @@ public String getCatalog() throws SQLException {
206214
@Override
207215
public void setTransactionIsolation(int level) throws SQLException {
208216
checkOpen();
209-
if (TRANSACTION_NONE != level) {
217+
if (!config.isIgnoreUnsupportedRequests() && TRANSACTION_NONE != level) {
210218
throw new SQLFeatureNotSupportedException("setTransactionIsolation not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
211219
}
212220
}
@@ -243,19 +251,29 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res
243251
@Override
244252
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
245253
checkOpen();
246-
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
254+
if (!config.isIgnoreUnsupportedRequests()) {
255+
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
256+
}
257+
258+
return null;
247259
}
248260

249261
@Override
250262
public Map<String, Class<?>> getTypeMap() throws SQLException {
251263
checkOpen();
252-
throw new SQLFeatureNotSupportedException("getTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
264+
if (!config.isIgnoreUnsupportedRequests()) {
265+
throw new SQLFeatureNotSupportedException("getTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
266+
}
267+
268+
return null;
253269
}
254270

255271
@Override
256272
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
257273
checkOpen();
258-
throw new SQLFeatureNotSupportedException("setTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
274+
if (!config.isIgnoreUnsupportedRequests()) {
275+
throw new SQLFeatureNotSupportedException("setTypeMap not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
276+
}
259277
}
260278

261279
@Override
@@ -273,13 +291,21 @@ public int getHoldability() throws SQLException {
273291
@Override
274292
public Savepoint setSavepoint() throws SQLException {
275293
checkOpen();
276-
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
294+
if (!config.isIgnoreUnsupportedRequests()) {
295+
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
296+
}
297+
298+
return null;
277299
}
278300

279301
@Override
280302
public Savepoint setSavepoint(String name) throws SQLException {
281303
checkOpen();
282-
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
304+
if (!config.isIgnoreUnsupportedRequests()) {
305+
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
306+
}
307+
308+
return null;
283309
}
284310

285311
@Override
@@ -293,7 +319,9 @@ public void rollback(Savepoint savepoint) throws SQLException {
293319
@Override
294320
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
295321
checkOpen();
296-
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
322+
if (!config.isIgnoreUnsupportedRequests()) {
323+
throw new SQLFeatureNotSupportedException("Savepoint not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
324+
}
297325
}
298326

299327
@Override
@@ -311,7 +339,11 @@ public PreparedStatement prepareStatement(String sql, int resultSetType, int res
311339
@Override
312340
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
313341
checkOpen();
314-
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
342+
if (!config.isIgnoreUnsupportedRequests()) {
343+
throw new SQLFeatureNotSupportedException("CallableStatement not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
344+
}
345+
346+
return null;
315347
}
316348

317349
@Override
@@ -350,25 +382,41 @@ public PreparedStatement prepareStatement(String sql, String[] columnNames) thro
350382
@Override
351383
public Clob createClob() throws SQLException {
352384
checkOpen();
353-
throw new SQLFeatureNotSupportedException("Clob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
385+
if (!config.isIgnoreUnsupportedRequests()) {
386+
throw new SQLFeatureNotSupportedException("Clob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
387+
}
388+
389+
return null;
354390
}
355391

356392
@Override
357393
public Blob createBlob() throws SQLException {
358394
checkOpen();
359-
throw new SQLFeatureNotSupportedException("Blob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
395+
if (!config.isIgnoreUnsupportedRequests()) {
396+
throw new SQLFeatureNotSupportedException("Blob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
397+
}
398+
399+
return null;
360400
}
361401

362402
@Override
363403
public NClob createNClob() throws SQLException {
364404
checkOpen();
365-
throw new SQLFeatureNotSupportedException("NClob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
405+
if (!config.isIgnoreUnsupportedRequests()) {
406+
throw new SQLFeatureNotSupportedException("NClob not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
407+
}
408+
409+
return null;
366410
}
367411

368412
@Override
369413
public SQLXML createSQLXML() throws SQLException {
370414
checkOpen();
371-
throw new SQLFeatureNotSupportedException("SQLXML not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
415+
if (!config.isIgnoreUnsupportedRequests()) {
416+
throw new SQLFeatureNotSupportedException("SQLXML not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
417+
}
418+
419+
return null;
372420
}
373421

374422
@Override
@@ -445,7 +493,11 @@ public Array createArrayOf(String typeName, Object[] elements) throws SQLExcepti
445493
@Override
446494
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
447495
//TODO: Should this be supported?
448-
throw new SQLFeatureNotSupportedException("createStruct not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
496+
if (!config.isIgnoreUnsupportedRequests()) {
497+
throw new SQLFeatureNotSupportedException("createStruct not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
498+
}
499+
500+
return null;
449501
}
450502

451503
@Override
@@ -462,19 +514,27 @@ public String getSchema() throws SQLException {
462514

463515
@Override
464516
public void abort(Executor executor) throws SQLException {
465-
throw new SQLFeatureNotSupportedException("abort not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
517+
if (!config.isIgnoreUnsupportedRequests()) {
518+
throw new SQLFeatureNotSupportedException("abort not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
519+
}
466520
}
467521

468522
@Override
469523
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
470524
//TODO: Should this be supported?
471-
throw new SQLFeatureNotSupportedException("setNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
525+
if (!config.isIgnoreUnsupportedRequests()) {
526+
throw new SQLFeatureNotSupportedException("setNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
527+
}
472528
}
473529

474530
@Override
475531
public int getNetworkTimeout() throws SQLException {
476532
//TODO: Should this be supported?
477-
throw new SQLFeatureNotSupportedException("getNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
533+
if (!config.isIgnoreUnsupportedRequests()) {
534+
throw new SQLFeatureNotSupportedException("getNetworkTimeout not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
535+
}
536+
537+
return -1;
478538
}
479539

480540
@Override

jdbc-v2/src/main/java/com/clickhouse/jdbc/PreparedStatementImpl.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ public void setCharacterStream(int parameterIndex, Reader x, int length) throws
235235
@Override
236236
public void setRef(int parameterIndex, Ref x) throws SQLException {
237237
checkClosed();
238-
throw new SQLFeatureNotSupportedException("Ref is not supported.", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
238+
if (!connection.config.isIgnoreUnsupportedRequests()) {
239+
throw new SQLFeatureNotSupportedException("Ref is not supported.", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
240+
}
239241
}
240242

241243
@Override

0 commit comments

Comments
 (0)