Skip to content

Commit 2e57790

Browse files
committed
removed:
- PreparedStatementImpl:getMetadata - sslmode
1 parent 0a06285 commit 2e57790

File tree

7 files changed

+11
-71
lines changed

7 files changed

+11
-71
lines changed

client-v2/src/main/java/com/clickhouse/client/api/ClientConfigProperties.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,6 @@ public enum ClientConfigProperties {
9292

9393
SSL_KEY_STORE_PASSWORD("key_store_password"),
9494

95-
SSL_MODE("sslmode", "strict", Arrays.asList("strict", "none")),
96-
9795
SSL_KEY("ssl_key"),
9896

9997
CA_CERTIFICATE("sslrootcert"),

client-v2/src/main/java/com/clickhouse/client/api/internal/HttpAPIClientHelper.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,6 @@ public SSLContext createSSLContext() {
175175
} catch (SSLException e) {
176176
throw new ClientMisconfigurationException("Failed to create SSL context from certificates", e);
177177
}
178-
} else if ("none".equals(chConfiguration.get(ClientConfigProperties.SSL_MODE.getKey()))) {
179-
try {
180-
sslContext = SSLContext.getInstance("TLS");
181-
sslContext.init(new KeyManager[0], new TrustManager[]{new TrustAllManager()}, new SecureRandom());
182-
} catch (NoSuchAlgorithmException | KeyManagementException e) {
183-
throw new ClientException("Failed to create none validating SSL context", e);
184-
}
185178
}
186179
return sslContext;
187180
}

client-v2/src/test/java/com/clickhouse/client/ClientTests.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,6 @@ private static Client[] secureClientProvider() throws Exception {
6565
.setPassword("")
6666
.setRootCertificate("containers/clickhouse-server/certs/localhost.crt")
6767
.build(),
68-
new Client.Builder()
69-
.addEndpoint("https://" + node.getHost() + ":" + node.getPort())
70-
.setUsername("default")
71-
.setPassword("")
72-
.setOption(ClientConfigProperties.SSL_MODE.getKey(), "none")
73-
.build(),
7468
new Client.Builder()
7569
.addEndpoint(Protocol.HTTP, node.getHost(), node.getPort(), true)
7670
.setUsername("default")

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,11 @@
33

44
import com.clickhouse.client.api.ClientConfigProperties;
55
import com.clickhouse.client.config.ClickHouseClientOption;
6-
import com.clickhouse.jdbc.internal.JdbcConfiguration;
76
import com.clickhouse.jdbc.internal.ExceptionUtils;
7+
import com.clickhouse.jdbc.internal.JdbcConfiguration;
88
import org.slf4j.Logger;
99
import org.slf4j.LoggerFactory;
1010

11-
import java.io.InputStream;
1211
import java.sql.Connection;
1312
import java.sql.DriverManager;
1413
import java.sql.DriverPropertyInfo;
@@ -33,11 +32,14 @@ public class Driver implements java.sql.Driver {
3332
private final DataSourceImpl dataSource;
3433

3534
public static String frameworksDetected = null;
35+
3636
public static class FrameworksDetection {
3737
private static final List<String> FRAMEWORKS_TO_DETECT = Arrays.asList("apache.spark");
3838
static volatile String frameworksDetected = null;
3939

40-
private FrameworksDetection() {}
40+
private FrameworksDetection() {
41+
}
42+
4143
public static String getFrameworksDetected() {
4244
if (frameworksDetected == null) {//Only detect frameworks once
4345
Set<String> inferredFrameworks = new LinkedHashSet<>();
@@ -98,22 +100,21 @@ public Driver(DataSourceImpl dataSourceImpl) {
98100

99101
public static void load() {
100102
try {
101-
DriverManager.registerDriver(DriverHolder.INSTANCE);
103+
DriverManager.registerDriver(INSTANCE);
102104
} catch (SQLException e) {
103105
log.error("Failed to register ClickHouse JDBC driver", e);
104106
}
105107
}
106108

107109
public static void unload() {
108110
try {
109-
DriverManager.deregisterDriver(DriverHolder.INSTANCE);
111+
DriverManager.deregisterDriver(INSTANCE);
110112
} catch (SQLException e) {
111113
log.error("Failed to deregister ClickHouse JDBC driver", e);
112114
}
113115
}
114116

115117

116-
117118
@Override
118119
public Connection connect(String url, Properties info) throws SQLException {
119120
if (!acceptsURL(url)) {
@@ -164,7 +165,5 @@ public java.util.logging.Logger getParentLogger() throws SQLFeatureNotSupportedE
164165
throw new SQLFeatureNotSupportedException("Method not supported", ExceptionUtils.SQL_STATE_FEATURE_NOT_SUPPORTED);
165166
}
166167

167-
private static final class DriverHolder {
168-
private static final Driver INSTANCE = new Driver();
169-
}
168+
private static final Driver INSTANCE = new Driver();
170169
}

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

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -303,26 +303,7 @@ public void setArray(int parameterIndex, Array x) throws SQLException {
303303
@Override
304304
public ResultSetMetaData getMetaData() throws SQLException {
305305
checkClosed();
306-
if (this.currentResultSet != null) {
307-
return currentResultSet.getMetaData();
308-
} else if (statementType != StatementType.SELECT) {
309-
return null;
310-
}
311-
312-
String sql = compileSql(sqlSegments);
313-
String describe = String.format("describe (\n%s\n)", sql);
314-
315-
List<ClickHouseColumn> columns = new ArrayList<>();
316-
try (Statement stmt = connection.createStatement()) {
317-
try (ResultSet rs = stmt.executeQuery(describe)) {
318-
while (rs.next()) {
319-
ClickHouseColumn column = ClickHouseColumn.of(rs.getString(1), rs.getString(2));
320-
columns.add(column);
321-
}
322-
}
323-
}
324-
TableSchema schema = new TableSchema(columns);
325-
return new com.clickhouse.jdbc.metadata.ResultSetMetaData(schema);
306+
return null;
326307
}
327308

328309
@Override

jdbc-v2/src/main/java/com/clickhouse/jdbc/metadata/ResultSetMetaData.java

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.clickhouse.jdbc.metadata;
22

33
import java.sql.SQLException;
4-
import java.util.Objects;
54

65
import com.clickhouse.client.api.metadata.TableSchema;
76
import com.clickhouse.data.ClickHouseColumn;
@@ -12,32 +11,21 @@
1211

1312
public class ResultSetMetaData implements java.sql.ResultSetMetaData, JdbcV2Wrapper {
1413
private final ResultSetImpl resultSet;
15-
private final TableSchema schema;
16-
1714
public ResultSetMetaData(ResultSetImpl resultSet) {
1815
this.resultSet = resultSet;
19-
this.schema = null; // result set schema is lazy
20-
}
21-
22-
public ResultSetMetaData(TableSchema schema) {
23-
this.resultSet = null;
24-
this.schema = schema;
2516
}
2617

2718
private ClickHouseColumn getColumn(int column) throws SQLException {
2819
if (column < 1 || column > getColumnCount()) {
2920
throw new SQLException("Column index out of range: " + column, ExceptionUtils.SQL_STATE_CLIENT_ERROR);
3021
}
31-
TableSchema schema = resultSet != null ? resultSet.getSchema() : this.schema;
32-
assert schema != null : "Schema is null";
33-
return schema.getColumns().get(column - 1);
22+
return resultSet.getSchema().getColumns().get(column - 1);
3423
}
3524

3625
@Override
3726
public int getColumnCount() throws SQLException {
3827
try {
39-
TableSchema schema = resultSet != null ? resultSet.getSchema() : this.schema;
40-
assert schema != null : "Schema is null";
28+
TableSchema schema = resultSet.getSchema();
4129
return schema.getColumns().size();
4230
} catch (Exception e) {
4331
throw ExceptionUtils.toSqlState(e);

jdbc-v2/src/test/java/com/clickhouse/jdbc/PreparedStatementTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -491,17 +491,4 @@ void testStatementSplit() throws Exception {
491491
}
492492
}
493493
}
494-
495-
@Test(groups = { "integration" })
496-
void testPreparedStatementMd() throws Exception {
497-
try (Connection conn = getJdbcConnection()) {
498-
try (PreparedStatement stmt = conn.prepareStatement("select 1::Int32 as value")) {
499-
ResultSetMetaData md = stmt.getMetaData();
500-
assertNotNull(md);
501-
assertEquals(md.getColumnCount(), 1);
502-
assertEquals(md.getColumnName(1), "value");
503-
assertEquals(md.getColumnType(1), Types.INTEGER);
504-
}
505-
}
506-
}
507494
}

0 commit comments

Comments
 (0)