File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed
jdbc-v2/src/main/java/com/clickhouse/jdbc Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change 22
33import com .clickhouse .client .api .Client ;
44import com .clickhouse .client .api .data_formats .ClickHouseBinaryFormatReader ;
5+ import com .clickhouse .client .api .query .GenericRecord ;
56import com .clickhouse .client .api .query .QueryResponse ;
67import com .clickhouse .client .api .query .QuerySettings ;
78import com .clickhouse .jdbc .internal .JdbcConfiguration ;
@@ -67,16 +68,10 @@ public void setDefaultQuerySettings(QuerySettings settings) {
6768 }
6869
6970 private String getServerVersion () throws SQLException {
70- try (QueryResponse response = client .query ("SELECT version()" ).get (30 , TimeUnit .SECONDS )) {
71- // Create a reader to access the data in a convenient way
72- ClickHouseBinaryFormatReader reader = client .newBinaryFormatReader (response );
73- // Read the next record from stream and parse it as a string
74- reader .next ();
75- return reader .getString (0 );
76- } catch (Exception e ) {
77- log .error ("Failed to retrieve server version." , e );
78- throw new SQLException ("Failed to retrieve server version." , e );
79- }
71+ GenericRecord result = client .queryAll ("SELECT version() as server_version" ).stream ()
72+ .findFirst ().orElseThrow (() -> new SQLException ("Failed to retrieve server version." ));
73+
74+ return result .getString ("server_version" );
8075 }
8176
8277 public int getMajorVersion () throws SQLException {
You can’t perform that action at this time.
0 commit comments