Clickhouse客户端报错-Read timed out

一、报错信息

报错信息:07000][159] Read timed out, server ClickHouseNode [uri=http://172.21.48.138:8123/default, options={session_id=DataGrip_3e9296ff-87ef-4a65-a4cb-71338d6d053a}]@-631443168

二、解决办法

1、在datagrip、idea等可视化客户端,在URL模板中添加参数配置即可。
jdbc:clickhouse://{host}:{port}[/{database}]?socket_timeout=600000

2、java连接方式

public static void initialCK(String sql){
        try {
            ClickHouseProperties properties = new ClickHouseProperties();
            properties.setSocketTimeout(600000);

            ClickHouseDataSource dataSource = new ClickHouseDataSource(Config.CLICKHOUSE_URL, properties);
            ClickHouseConnection connection = dataSource.getConnection();
            ClickHouseStatement statement = connection.createStatement();
            ResultSet resultSet = statement.executeQuery(sql);
//        while (resultSet.next()) {
            // ResultSet 的下标值从 1 开始,不可使用 0,否则越界,报 ArrayIndexOutOfBoundsException 异常
//            System.out.println(resultSet.getInt(1));
//        }
            try {
                if(resultSet != null){
                    resultSet.close();
                }
                if(statement != null){
                    statement.close();
                }
                if(connection != null){
                    connection.close();
                }
            } catch (SQLException e) {
                e.printStackTrace();
            }
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }


    }

你可能感兴趣的:(clickhouse,clickhouse,linux,运维)