1111import com .clickhouse .client .ClickHouseNodeSelector ;
1212import com .clickhouse .client .ClickHouseProtocol ;
1313import com .clickhouse .client .ClickHouseResponse ;
14+ import com .clickhouse .client .ClickHouseServerForTest ;
1415import com .clickhouse .client .api .Client ;
1516import com .clickhouse .client .api .ConnectionReuseStrategy ;
1617import com .clickhouse .client .api .enums .Protocol ;
5657@ State (Scope .Benchmark )
5758public class BenchmarkBase {
5859 private static final Logger LOGGER = LoggerFactory .getLogger (BenchmarkBase .class );
59-
6060 protected ClickHouseClient clientV1 ;
6161 protected Client clientV2 ;
62- protected static Connection jdbcV1 = null ;
63- protected static Connection jdbcV2 = null ;
62+ protected static Connection jdbcV1 ;
63+ protected static Connection jdbcV2 ;
6464
6565 @ Setup (Level .Iteration )
6666 public void setUpIteration () {
@@ -265,14 +265,13 @@ protected static Client getClientV2(boolean includeDb) {
265265 .setDefaultDatabase (includeDb ? DB_NAME : "default" )
266266 .build ();
267267 }
268-
268+
269269 protected static Connection getJdbcV1 () {
270270 Properties properties = new Properties ();
271271 properties .put ("user" , getUsername ());
272272 properties .put ("password" , getPassword ());
273-
273+
274274 ClickHouseNode node = getServer ();
275- LOGGER .info ("clickhouse endpoint [{}:{}]" , node .getHost (), node .getPort ());
276275 Connection jdbcV1 = null ;
277276 try {
278277 jdbcV1 = new ClickHouseDriver ().connect (String .format ("jdbc:clickhouse://%s:%s?clickhouse.jdbc.v1=true" , node .getHost (), node .getPort ()), properties );
@@ -281,21 +280,20 @@ protected static Connection getJdbcV1() {
281280 }
282281 return jdbcV1 ;
283282 }
284-
285- protected static Connection getJdbcV2 () {
283+
284+ protected static Connection getJdbcV2 () throws SQLException {
286285 Properties properties = new Properties ();
287286 properties .put ("user" , getUsername ());
288287 properties .put ("password" , getPassword ());
289288
290289 ClickHouseNode node = getServer ();
291- LOGGER .info ("clickhouse endpoint [{}:{}]" , node .getHost (), node .getPort ());
292-
293290 Connection jdbcV2 = null ;
294291 try {
295292 jdbcV2 = new ClickHouseDriver ().connect (String .format ("jdbc:clickhouse://%s:%s" , node .getHost (), node .getPort ()), properties );
296293 } catch (SQLException e ) {
297294 LOGGER .error (e .getMessage ());
298295 }
296+
299297 return jdbcV2 ;
300298 }
301299
0 commit comments