我们如何使用java clickhouse-client批量插入?
clickhouse-client
的性能远远优于 clickhouse-jdbc
,我们确实为批量插入准备了PreparedStatment。但是我们如何使用clickhouse-client
进行批量插入。
try (ClickHouseClient client = ClickHouseClient.newInstance(preferredProtocol);
ClickHouseResponse response = client.connect(server)
.format(preferredFormat)
.query("insert query")
.params("param for insert query").execute().get()) {
}
}
由于http请求是无状态且单一的,但是是否有任何其他类或方法可以批量插入,或者我们需要动态构建插入查询,并使用多个值作为查询语句的参数?
Performance of clickhouse-client
is far better than clickhouse-jdbc
where we do have preparedStatment for batchInsert. But how can we do Batch insert using clickhouse-client
.
try (ClickHouseClient client = ClickHouseClient.newInstance(preferredProtocol);
ClickHouseResponse response = client.connect(server)
.format(preferredFormat)
.query("insert query")
.params("param for insert query").execute().get()) {
}
}
As http request is stateless and single but is there any other class or way to have batch insert OR we need to dynamically build insert query with multiple VALUES as parameters for query statement?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
例如 https://github.com/ClickHouse/clickhouse-jdbc
你只需要实现
myInputStream
。我有一个问题,你的数据来源是什么?它是一个文件吗?或者某种格式的数据流?
For example https://github.com/ClickHouse/clickhouse-jdbc
You just need to implement
myInputStream
.I have a question, what is the source of your data? Is it a file? Or stream of data in some format?