Skip to content

Commit 5faebc4

Browse files
author
Paultagoras
committed
Update Client.java
1 parent 0ba5aed commit 5faebc4

File tree

1 file changed

+7
-2
lines changed
  • client-v2/src/main/java/com/clickhouse/client/api

1 file changed

+7
-2
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ public class Client implements AutoCloseable {
155155
private final ColumnToMethodMatchingStrategy columnToMethodMatchingStrategy;
156156

157157
// Server context
158-
private String serverUser;
159158
private String serverVersion;
160159

161160
private Client(Set<String> endpoints, Map<String,String> configuration, boolean useNewImplementation,
@@ -191,7 +190,7 @@ private void updateServerContext() {
191190
try (QueryResponse response = this.query("SELECT currentUser() AS user, timezone() AS timezone, version() AS version LIMIT 1").get()) {
192191
try (ClickHouseBinaryFormatReader reader = this.newBinaryFormatReader(response)) {
193192
if (reader.next() != null) {
194-
serverUser = reader.getString("user");
193+
this.configuration.put(ClientConfigProperties.USER.getKey(), reader.getString("user"));
195194
this.configuration.put(ClientConfigProperties.SERVER_TIMEZONE.getKey(), reader.getString("timezone"));
196195
serverVersion = reader.getString("version");
197196
}
@@ -202,6 +201,8 @@ private void updateServerContext() {
202201
}
203202

204203

204+
205+
205206
/**
206207
* Returns default database name that will be used by operations if not specified.
207208
*
@@ -2147,6 +2148,10 @@ public String getUser() {
21472148
return this.configuration.get(ClientConfigProperties.USER.getKey());
21482149
}
21492150

2151+
public String getServerVersion() {
2152+
return this.serverVersion;
2153+
}
2154+
21502155
/**
21512156
* Sets list of DB roles that should be applied to each query.
21522157
*

0 commit comments

Comments
 (0)