当前位置:网站首页>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()中的语句就行
边栏推荐
- 副作用和序列点
- 【赛事预告】云上开发,高效智能——第二届阿里云ECS CloudBuild开发者大赛即将启动
- 阿里云张新涛:异构计算为数字经济提供澎湃动力
- 167. 两数之和 II - 输入有序数组
- 携手数字人、数字空间、XR平台,阿里云与伙伴共同建设“新视界”
- Solution: find the position of the first and last element in a sorted array (personal notes)
- C语言数组典型应用代码详细讲解—高手误入(逐步代码详解)
- GPIO的输入输出详解
- Integer overflow and printing
- 200 多家 ISV 入驻!阿里云计算巢发布一周年
猜你喜欢

Detailed explanation of serial port communication

Best practices for elastic computing in the game industry

321,京东言犀×NLPCC 2022挑战赛开赛!

365 day challenge leetcode 1000 questions - day 040 design jump table + avoid flooding + find the latest grouping with size M + color ball with reduced sales value

During the appointment, the 2022 JD cloud industrial integration new product launch was launched online

The road to success in R & D efficiency of 1000 person Internet companies

QT series - Installation

刷题狂魔—LeetCode之剑指offer58 - II. 左旋转字符串 详解

Live broadcast preview | how to save 30% labor cost and shorten 80% trademark processing cycle?

QML type: mousearea
随机推荐
【活动预告】云上数字工厂与中小企业数字化转型创新论坛
题解:在一个排序数组中查找元素第一个和最后一个的位置 (个人笔记)
Occt learning 003 - MFC single document project
【剑指offer】— 详解库函数atoi以及模拟实现atoi函数
vim编辑器使用
Introduction to array learning simple question sum of two numbers
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
167. Sum of two numbers II - enter an ordered array
时间复杂度和空间复杂度
【C语言系列】— 把同学弄糊涂的 “常量” 与 “变量”
Container security open source detection tool - veinmind (mirror backdoor, malicious samples, sensitive information, weak password, etc.)
Time complexity and space complexity
直播预告|如何节省30%人工成本,缩短80%商标办理周期?
·来一篇编程之路的自我介绍吧·
Solution: find the position of the first and last element in a sorted array (personal notes)
实现简单的数据库查询(不完整)
京东云分布式链路追踪在金融场景的最佳实践
【C语言系列】— 打印100~200之间的素数
Alibaba cloud Zhang Xintao: heterogeneous computing provides surging power for the digital economy
指针