Skip to content

Commit 9f19d82

Browse files
authored
Merge pull request #2514 from ClickHouse/fix_using_new_api
fixed j8 compatibility
2 parents 34a4d83 + 3be1182 commit 9f19d82

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,22 +430,22 @@ public boolean getMoreResults(int current) throws SQLException {
430430
return false; // false indicates that no more results (or it is an update count)
431431
}
432432

433-
@Override
433+
// @Override
434434
public String enquoteLiteral(String val) throws SQLException {
435435
return SQLUtils.enquoteLiteral(val);
436436
}
437437

438-
@Override
438+
// @Override
439439
public String enquoteIdentifier(String identifier, boolean alwaysQuote) throws SQLException {
440440
return SQLUtils.enquoteIdentifier(identifier, alwaysQuote);
441441
}
442442

443-
@Override
443+
// @Override
444444
public boolean isSimpleIdentifier(String identifier) throws SQLException {
445445
return SQLUtils.isSimpleIdentifier(identifier);
446446
}
447447

448-
@Override
448+
// @Override
449449
public String enquoteNCharLiteral(String val) throws SQLException {
450450
if (val == null) {
451451
throw new NullPointerException();

jdbc-v2/src/main/java/com/clickhouse/jdbc/internal/JdbcConfiguration.java

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
import com.clickhouse.jdbc.Driver;
88
import com.google.common.collect.ImmutableMap;
99

10+
import java.io.UnsupportedEncodingException;
1011
import java.net.URI;
1112
import java.net.URISyntaxException;
1213
import java.net.URLDecoder;
1314
import java.nio.charset.StandardCharsets;
15+
import java.nio.charset.UnsupportedCharsetException;
1416
import java.sql.DriverPropertyInfo;
1517
import java.sql.SQLException;
1618
import java.util.Comparator;
@@ -195,19 +197,23 @@ private Map<String, String> parseUrl(String url) throws SQLException {
195197
}
196198
if (uri.getQuery() != null && !uri.getQuery().trim().isEmpty()) {
197199
for (String pair : uri.getRawQuery().split("&")) {
198-
String[] p = pair.split("=", 2);
199-
if (p.length != 2 || p[0] == null || p[1] == null) {
200-
throw new SQLException("Invalid query parameter '" + pair + "'");
200+
try {
201+
String[] p = pair.split("=", 2);
202+
if (p.length != 2 || p[0] == null || p[1] == null) {
203+
throw new SQLException("Invalid query parameter '" + pair + "'");
204+
}
205+
String key = URLDecoder.decode(p[0], StandardCharsets.UTF_8.name());
206+
if (key == null || key.trim().isEmpty() || !PATTERN_HTTP_TOKEN.matcher(key).matches()) {
207+
throw new SQLException("Invalid query parameter key in pair'" + pair + "'");
208+
}
209+
String value = URLDecoder.decode(p[1], StandardCharsets.UTF_8.name());
210+
if (value == null || value.trim().isEmpty() || "=".equals(value)) {
211+
throw new SQLException("Invalid query parameter value in pair '" + pair + "'");
212+
}
213+
properties.put(key.trim(), value);
214+
} catch (UnsupportedEncodingException e) {
215+
throw new SQLException("Internal error'", e);
201216
}
202-
String key = URLDecoder.decode(p[0], StandardCharsets.UTF_8);
203-
if (key == null || key.trim().isEmpty() || !PATTERN_HTTP_TOKEN.matcher(key).matches()) {
204-
throw new SQLException("Invalid query parameter key in pair'" + pair + "'");
205-
}
206-
String value = URLDecoder.decode(p[1], StandardCharsets.UTF_8);
207-
if (value == null || value.trim().isEmpty() || "=".equals(value)) {
208-
throw new SQLException("Invalid query parameter value in pair '" + pair + "'");
209-
}
210-
properties.put(key.trim(), value);
211217
}
212218
}
213219
return properties;

0 commit comments

Comments
 (0)