当前位置:网站首页>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()中的语句就行
边栏推荐
猜你喜欢

Live broadcast preview | how to improve enterprise immunity through "intelligent edge security"?

MySQL的详细安装使用教程(保姆式安装图文讲解)

三次握手四次挥手针对面试总结

QML type: mousearea

科班同学真的了解未来的职业规划吗?

Helm chart for Kubernetes

关于局部变量

321, Jingdong Yanxi × Nlpcc 2022 challenge starts!

【C语言系列】—深度解剖数据在内存中的存储(一) 暑假开篇

阿里云联合鼎捷软件发布云上数字工厂解决方案,实现云MES系统本地化部署
随机推荐
Day 1
js深拷贝-笔记
Thousands of databases, physical machines all over the country, JD logistics full volume cloud live record | interview with excellent technical team
来!看排名一年上升16位的ClickHouse,如何在京东落地实践
Occt learning 002 - environment construction
Occt learning 003 - MFC single document project
[event preview] cloud development, efficient and intelligent - the second Alibaba cloud ECS cloudbuild developer competition is about to start
预约中,2022京东云产业融合新品发布会线上开启
Alibaba cloud architect details nine trends in the game industry
阿里云架构师细说游戏行业九大趋势
2022数学建模竞赛暑期培训讲座——最优化方法:目标规划
Introduction to array learning simple question sum of two numbers
vim编辑器使用
Common shortcut keys for Ad
Helm chart for Kubernetes
牛客网编程题—【WY22 Fibonacci数列】和【替换空格】详解
Time complexity and space complexity
321, Jingdong Yanxi × Nlpcc 2022 challenge starts!
Custom QML control: imagebutton
数据库操作 Day 6