当前位置:网站首页>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()中的语句就行
边栏推荐
- 全局components组件注册
- Alibaba cloud and Dingjie software released the cloud digital factory solution to realize the localized deployment of cloud MES system
- 使用微信小程序扫码登录系统PC端web的功能
- C语言 N皇后问题
- Best practices for elastic computing in the game industry
- 167. Sum of two numbers II - enter an ordered array
- 【C语言系列】— 不创造第三个变量,实现两个数的交换
- ANSI C类型限定符
- 数据泄漏、删除事件频发,企业应如何构建安全防线?
- C语言数组典型应用代码详细讲解—高手误入(逐步代码详解)
猜你喜欢

重定向和文件

Thousands of databases, physical machines all over the country, JD logistics full volume cloud live record | interview with excellent technical team

数据库操作 Day 6

Li Yan, CEO of parallel cloud: cloudxr, opens the channel to the metauniverse

More than 200 ISVs have settled in! The first anniversary of Alibaba cloud computing nest

365天挑战LeetCode1000题——Day 035 每日一题 + 二分查找 13

365天挑战LeetCode1000题——Day 036 二叉树剪枝 + 子数组和排序后的区间和 + 删除最短的子数组使剩余数组有序

C language one-dimensional array

Best practices for elastic computing in the game industry

全局components组件注册
随机推荐
Solution: find the position of the first and last element in a sorted array (personal notes)
365天挑战LeetCode1000题——Day 035 每日一题 + 二分查找 13
167. Sum of two numbers II - enter an ordered array
VIM editor use
Side effects and sequence points
ANSI C类型限定符
321, Jingdong Yanxi × Nlpcc 2022 challenge starts!
Differences between texture2d and texture2dproj under webgl1.0
365 day challenge leetcode 1000 questions - day 037 elements and the maximum side length of squares less than or equal to the threshold + the number of subsequences that meet the conditions
Occt learning 002 - environment construction
三次握手四次挥手针对面试总结
微信小程序视频上传组件直接上传至阿里云OSS
Occt learning 003 - MFC single document project
Day 3
省市区三级联动(简单又完美)
Together with digital people, digital space and XR platform, Alibaba cloud and its partners jointly build a "new vision"
Day 2
NVIDIA Zhou Xijian: the last mile from design to digital marketing
刷题狂魔—LeetCode之剑指offer58 - II. 左旋转字符串 详解
抢先预约 | 阿里云无影云应用线上发布会预约开启