当前位置:网站首页>Clickhouse learning (XI) clickhouseapi operation
Clickhouse learning (XI) clickhouseapi operation
2022-07-29 05:34:00 【Crying dogs in the sun】
Catalog
establish maven
stay pom Add clickhouse rely on 
<!-- Clickhouse -->
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.1</version>
</dependency>

To write API
import java.sql.*;
/** * @author Male feather * date: 2021/8/19 * desc: Simple api To write */
public class ClickHouse_Select {
public static void main(String[] args) throws SQLException {
Connection connection = null;
PreparedStatement preparedStatement =null;
ResultSet resultSet =null;
try {
// TODO 1. Load driver class
Class.forName("ru.yandex.clickhouse.ClickHouseDriver");
// TODO 2. Create connection
connection = DriverManager.getConnection("jdbc:clickhouse://spark01:8123");
// TODO 3. establish PreparedStatement object
preparedStatement = connection.prepareStatement("select * from test_binlog.user");
// TODO 4. perform
resultSet = preparedStatement.executeQuery();
// TODO 5. Output results
System.out.println(resultSet);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
} finally {
connection.close();
preparedStatement.close();
resultSet.close();
}
}
}
Delete , The insertion operation is similar, but it is modified prepareStatement() The statement in is OK
边栏推荐
猜你喜欢

C language first level pointer

Day 5

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

One dimensional array exercise

ClickHouse学习(十一)clickhouseAPI操作

力扣994:腐烂的橘子(BFS)

串口通讯部分详解

【C语言系列】—深度解剖数据在内存中的存储(二)-浮点型

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

Together with digital people, digital space and XR platform, Alibaba cloud and its partners jointly build a "new vision"
随机推荐
存储类别
ClickHouse学习(四)SQL操作
抽象类与接口
MySQL的基础概念+数据库系统结构+拓展延申+基础命令学习
321, Jingdong Yanxi × Nlpcc 2022 challenge starts!
ClickHouse学习(六)语法优化
递归的基本原理
数组学习之入门简单题 两数之和
小程序中的DOM对象元素块动态排序
Occt learning 001 - Introduction
ANSI C type qualifier
shell基本操作(下)
Day 3
PyQt5:第一章第1节:使用Qt组件创建一个用户界面-介绍
Abstract classes and interfaces
【C语言系列】— 一道递归小题目
Alibaba cloud and Dingjie software released the cloud digital factory solution to realize the localized deployment of cloud MES system
力扣994:腐烂的橘子(BFS)
The function of using wechat applet to scan code to log in to the PC web of the system
一维数组练习