4545import com .clickhouse .client .config .ClickHouseClientOption ;
4646import com .clickhouse .data .ClickHouseColumn ;
4747import com .clickhouse .data .ClickHouseFormat ;
48- import org .apache .hc .client5 .http .ConnectTimeoutException ;
4948import org .apache .hc .core5 .concurrent .DefaultThreadFactory ;
5049import org .apache .hc .core5 .http .ClassicHttpResponse ;
51- import org .apache .hc .core5 .http .ConnectionRequestTimeoutException ;
5250import org .apache .hc .core5 .http .HttpHeaders ;
5351import org .apache .hc .core5 .http .HttpStatus ;
54- import org .apache .hc .core5 .http .NoHttpResponseException ;
5552import org .slf4j .Logger ;
5653import org .slf4j .LoggerFactory ;
5754
6259import java .io .OutputStream ;
6360import java .lang .reflect .InvocationTargetException ;
6461import java .lang .reflect .Method ;
65- import java .net .ConnectException ;
66- import java .net .SocketTimeoutException ;
6762import java .net .URL ;
6863import java .nio .charset .StandardCharsets ;
6964import java .time .Duration ;
7772import java .util .LinkedHashMap ;
7873import java .util .List ;
7974import java .util .Map ;
80- import java .util .Properties ;
8175import java .util .Set ;
8276import java .util .StringJoiner ;
8377import java .util .TimeZone ;
@@ -185,12 +179,13 @@ private Client(Set<String> endpoints, Map<String,String> configuration, boolean
185179 LOG .info ("Using old http client implementation" );
186180 }
187181 this .columnToMethodMatchingStrategy = columnToMethodMatchingStrategy ;
188-
189-
190- updateServerContext ();
191182 }
192183
193- private void updateServerContext () {
184+ /**
185+ * Loads essential information about a server. Should be called after client creation.
186+ *
187+ */
188+ public void updateServerContext () {
194189 try (QueryResponse response = this .query ("SELECT currentUser() AS user, timezone() AS timezone, version() AS version LIMIT 1" ).get ()) {
195190 try (ClickHouseBinaryFormatReader reader = this .newBinaryFormatReader (response )) {
196191 if (reader .next () != null ) {
@@ -200,13 +195,10 @@ private void updateServerContext() {
200195 }
201196 }
202197 } catch (Exception e ) {
203- LOG . error ("Failed to get server info" , e );
198+ throw new ClientException ("Failed to get server info" , e );
204199 }
205200 }
206201
207-
208-
209-
210202 /**
211203 * Returns default database name that will be used by operations if not specified.
212204 *
0 commit comments