Skip to content

Commit 3ec1cf1

Browse files
author
Paultagoras
committed
Set database from the url path
1 parent a5131ef commit 3ec1cf1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,15 @@ public static Map<String, String> parseUrlParameters(URL url) {
601601
Map<String, String> params = new HashMap<>();
602602

603603
try {
604+
String path = url.getPath();
605+
path = path.substring(path.indexOf('/') + 1);
606+
LOG.debug("path: {}", path);
607+
if (!path.isBlank()) {
608+
params.put("database", path);
609+
} else {
610+
params.put("database", "default");
611+
}
612+
604613
String query = url.getQuery();
605614
if (query != null) {
606615
for (String pair : query.split("&")) {

0 commit comments

Comments
 (0)