<dependency>
<groupId>com.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.2-patch11</version>
</dependency>
Properties prop = new Properties();
prop.setProperty("username", "default");
prop.setProperty("password", "<password>");
Connection conn = DriverManager.getConnection("jdbc:ch:https://<host>:8443?insert_quorum=auto", prop);
Statement stmt = conn.createStatement();
stmt.execute("CREATE TABLE IF NOT EXISTS jdbc_test(idx Int8, str String) ENGINE = MergeTree ORDER BY idx");
try (PreparedStatement ps = conn.prepareStatement(
"insert into jdbc_test select col1, col2 from input('col1 Int8, col2 String')")) {
for (int i = 0; i < 10; i++) {
ps.setInt(1, i);
ps.setString(2, "test:" + i);
ps.addBatch();
}
ps.executeBatch();
}
ResultSet rs = stmt.executeQuery("select * from jdbc_test");
while (rs.next()) {
System.out.println(String.format("idx: %s str: %s", rs.getString(1), rs.getString(2)));
}