当前位置:网站首页>ClickHouse学习(十一)clickhouseAPI操作
ClickHouse学习(十一)clickhouseAPI操作
2022-07-29 05:09:00 【阳光里哭泣的狗】
创建maven
在pom中加入clickhouse依赖
<!-- Clickhouse -->
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.1</version>
</dependency>

编写API
import java.sql.*;
/** * @author 公羽 * date: 2021/8/19 * desc: 简单api编写 */
public class ClickHouse_Select {
public static void main(String[] args) throws SQLException {
Connection connection = null;
PreparedStatement preparedStatement =null;
ResultSet resultSet =null;
try {
// TODO 1.加载驱动类
Class.forName("ru.yandex.clickhouse.ClickHouseDriver");
// TODO 2.创建连接
connection = DriverManager.getConnection("jdbc:clickhouse://spark01:8123");
// TODO 3.创建PreparedStatement对象
preparedStatement = connection.prepareStatement("select * from test_binlog.user");
// TODO 4.执行
resultSet = preparedStatement.executeQuery();
// TODO 5.输出结果
System.out.println(resultSet);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
} finally {
connection.close();
preparedStatement.close();
resultSet.close();
}
}
}
删除,插入操作都类似只是修改prepareStatement()中的语句就行
边栏推荐
- 510000 prize pool invites you to fight! The second Alibaba cloud ECS cloudbuild developer competition is coming
- 51万奖池邀你参战!第二届阿里云ECS CloudBuild开发者大赛来袭
- 第一周总结
- 科班同学真的了解未来的职业规划吗?
- NVIDIA Zhou Xijian: the last mile from design to digital marketing
- 哈夫曼树以及哈夫曼编码在文件压缩上的应用
- C语言数组典型应用代码详细讲解—高手误入(逐步代码详解)
- Differences between texture2d and texture2dproj under webgl1.0
- 容器安全开源检测工具--问脉 VeinMind(镜像后门、恶意样本、敏感信息、弱口令等)
- 无重复字符的最长字串
猜你喜欢

C语言 一级指针

C language first level pointer

321, Jingdong Yanxi × Nlpcc 2022 challenge starts!

哈夫曼树以及哈夫曼编码在文件压缩上的应用

365 day challenge leetcode 1000 questions - day 042 array sequence number conversion + relative ranking discretization processing

Day 1

Alibaba cloud Zhang Xintao: heterogeneous computing provides surging power for the digital economy

京东云分布式链路追踪在金融场景的最佳实践

Occt learning 002 - environment construction

MySQL的基础概念+数据库系统结构+拓展延申+基础命令学习
随机推荐
【活动预告】云上数字工厂与中小企业数字化转型创新论坛
365 day challenge leetcode1000 question - distance between bus stops on day 038 + time-based key value storage + array closest to the target value after transforming the array and + maximum value at t
存储类别
利用Poi-tl在word模板表格单元格内一次插入多张图片和多行单元格相同数据自动合并的功能组件
Allocate memory: malloc() and free()
无重复字符的最长字串
51万奖池邀你参战!第二届阿里云ECS CloudBuild开发者大赛来袭
js深拷贝-笔记
C语言文件操作
【C语言系列】—三种方法模拟实现strlen库函数的方法
Day 1
省市区三级联动(简单又完美)
QML type: state state
C语言 N皇后问题
Cmu15-213 malloc lab experiment record
【C语言系列】— 一道递归小题目
Day 5
365天挑战LeetCode1000题——Day 036 二叉树剪枝 + 子数组和排序后的区间和 + 删除最短的子数组使剩余数组有序
365 day challenge leetcode 1000 questions - day 039 full binary tree inserter + find peak II + snapshot array
Solution: find the position of the first and last element in a sorted array (personal notes)