housepower / ClickHouse-Native-JDBC

ClickHouse Native Protocol JDBC implementation
https://housepower.github.io/ClickHouse-Native-JDBC/
Apache License 2.0
527 stars 145 forks source link

connection loss with state[IDLE], create new connection and reset state #419

Open zilet111 opened 2 years ago

zilet111 commented 2 years ago

Environment

    <dependency>
        <groupId>com.github.housepower</groupId>
        <artifactId>clickhouse-native-jdbc-shaded</artifactId>
        <version>2.6.5</version>
    </dependency>

Error logs

2022-05-11 00:55:03.392 [task-execute-thread-0] WARN c.g.h.c.NativeClient:82 - Attempt to read after eof. 2022-05-11 00:55:03.393 [task-execute-thread-0] WARN c.g.h.j.ClickHouseConnection:82 - connection loss with state[IDLE], create new connection and reset state

Other descriptions

I use the same statement object to execute multiple queries, but from the second query, the error shown above will be produced after each query. For instance, if I execute query for 5 times, the error log will be shown for 4 times. Although it does not affect the result of each query, I want to figure out the reason. Should I add some properties when create the connection? the example code:

   `Statement stmt = null; 
    for (String sql : queries) {
        try {
            if (stmt == null) {
                stmt = conn.createStatement();
            }
            stmt.executeQuery(sql);
        } catch (Exception e) {
            log.error("error when execute clickhouse query", e);
        } 
    }`

thx