Skip to content

Commit 077dfa8

Browse files
authored
Merge pull request #1880 from Am-phi/fix/JDBC_driver_prints_stack_trace_to_stdout
Fix JDBC driver prints stack trace to stdout
2 parents d994f91 + 9585171 commit 077dfa8

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

clickhouse-client/src/main/java/com/clickhouse/client/ClickHouseClient.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import com.clickhouse.data.ClickHouseValue;
4141
import com.clickhouse.data.ClickHouseValues;
4242
import com.clickhouse.data.ClickHouseWriter;
43+
import com.clickhouse.logging.Logger;
44+
import com.clickhouse.logging.LoggerFactory;
4345

4446
/**
4547
* A unified interface defines Java client for ClickHouse. A client can only
@@ -56,6 +58,7 @@
5658
* implementation properly in runtime.
5759
*/
5860
public interface ClickHouseClient extends AutoCloseable {
61+
Logger LOG = LoggerFactory.getLogger(ClickHouseClient.class);
5962

6063
/**
6164
* Returns a builder for creating a new client.
@@ -959,8 +962,8 @@ default boolean ping(ClickHouseNode server, int timeout) {
959962
.get(timeout, TimeUnit.MILLISECONDS)) {
960963
return resp != null;
961964
} catch (Exception e) {
962-
// ignore
963-
e.printStackTrace();
965+
LOG.debug("Failed to connect to the server", e);
966+
return false;
964967
}
965968
}
966969

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,7 @@ public boolean ping(long timeout) {
10371037
try (QueryResponse response = query("SELECT 1 FORMAT TabSeparated").get(timeout, TimeUnit.MILLISECONDS)) {
10381038
return true;
10391039
} catch (Exception e) {
1040+
LOG.debug("Failed to connect to the server", e);
10401041
return false;
10411042
}
10421043
} else {

0 commit comments

Comments
 (0)