@@ -265,16 +265,32 @@ protected static Client getClientV2(boolean includeDb) {
265265 .setDefaultDatabase (includeDb ? DB_NAME : "default" )
266266 .build ();
267267 }
268-
268+ private static String jdbcURLV1 (boolean isCloud ) {
269+ ClickHouseNode node = getServer ();
270+ if (isCloud ) {
271+ return String .format ("jdbc:clickhouse://%s:%s?clickhouse.jdbc.v1=true&ssl=true" , node .getHost (), node .getPort ());
272+ } else
273+ return String .format ("jdbc:clickhouse://%s:%s?clickhouse.jdbc.v1=true" , node .getHost (), node .getPort ());
274+ }
275+
276+ private static String jdbcURLV2 (boolean isCloud ) {
277+ ClickHouseNode node = getServer ();
278+ if (isCloud ) {
279+ return String .format ("jdbc:clickhouse://%s:%s?ssl=true" , node .getHost (), node .getPort ());
280+ } else
281+ return String .format ("jdbc:clickhouse://%s:%s" , node .getHost (), node .getPort ());
282+ }
283+
269284 protected static Connection getJdbcV1 () {
270285 Properties properties = new Properties ();
271286 properties .put ("user" , getUsername ());
272287 properties .put ("password" , getPassword ());
273-
274- ClickHouseNode node = getServer ();
288+
275289 Connection jdbcV1 = null ;
290+ String jdbcURL = jdbcURLV1 (isCloud ());
291+ LOGGER .info ("JDBC URL: " + jdbcURL );
276292 try {
277- jdbcV1 = new ClickHouseDriver ().connect (String . format ( "jdbc:clickhouse://%s:%s?clickhouse.jdbc.v1=true" , node . getHost (), node . getPort ()) , properties );
293+ jdbcV1 = new ClickHouseDriver ().connect (jdbcURL , properties );
278294 } catch (SQLException e ) {
279295 LOGGER .error (e .getMessage ());
280296 }
@@ -286,10 +302,12 @@ protected static Connection getJdbcV2() {
286302 properties .put ("user" , getUsername ());
287303 properties .put ("password" , getPassword ());
288304
289- ClickHouseNode node = getServer ();
290305 Connection jdbcV2 = null ;
306+ String jdbcURL = jdbcURLV1 (isCloud ());
307+ LOGGER .info ("JDBC URL: " + jdbcURL );
308+
291309 try {
292- jdbcV2 = new ClickHouseDriver ().connect (String . format ( "jdbc:clickhouse://%s:%s" , node . getHost (), node . getPort ()) , properties );
310+ jdbcV2 = new ClickHouseDriver ().connect (jdbcURL , properties );
293311 } catch (SQLException e ) {
294312 LOGGER .error (e .getMessage ());
295313 }
0 commit comments