public static void main(String[] args) throws SQLException {
final String DB_URL = "jdbc:clickhouse://github.demo.trial.altinity.cloud:8443?&ssl=true";
final String USER = "demo";
final String PASS = "demo";
final String QUERY = "SELECT count() FROM (select 3 x) WHERE x IN { tt 'table1' }";
ClickHouseExternalTable build = ClickHouseExternalTable.builder().name("table1").columns("id Int8")
.format(ClickHouseFormat.TSV)
.content(new ByteArrayInputStream("1".getBytes(StandardCharsets.US_ASCII)))
.build();
Connection conn = DriverManager.getConnection(DB_URL, USER, PASS);
PreparedStatement stmt = conn.prepareStatement(QUERY);
stmt.setObject(1, build);
ResultSet rs = stmt.executeQuery();
while (rs.next()) {
System.out.println(rs.getString(1));
}
}
WARNING: don't know how to handle parameter pair:
Exception in thread "main" java.sql.SQLException: Can't set parameter at index 1 due to no JDBC style '?' placeholder found in the query