ClickHouse的JDBC连接

时间:2021-07-26 16:47:51   收藏:0   阅读:0

1、增加依赖

 <dependency>
            <groupId>ru.yandex.clickhouse</groupId>
            <artifactId>clickhouse-jdbc</artifactId>
            <version>0.1.54</version>
        </dependency>

  

 

2、代码实现

public class ClickHouseJdbc {
    public static void main(String[] args) throws Exception {
        // 注册驱动
        Class.forName("ru.yandex.clickhouse.ClickHouseDriver");
        Connection conn = DriverManager.getConnection("jdbc:clickhouse://118.xx.xx.101:8123/db_test");
        PreparedStatement ps = conn.prepareStatement("select * from dis_all ");
        ResultSet set = ps.executeQuery();
        while (set.next()){
            String id = set.getString("id");
            String date = set.getString("date");
            System.out.println(id + "----" + date);
        }
        set.close();
        ps.close();
        conn.close();
        
    }
}

  

3、执行

技术图片

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!