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)