I have just installed a clickhouse server locally, with package clickhouse-server
linux package.
I created some java code to insert N rows in table and it works well via JDBC.
However to improve, performance I am now implementing it using batch instead of separate INSERTS, but the code below is not working and the executeBatch function is returning an array with length 0.
For testing purposes i created the following code:
public static void main(String[] args) throws PulsarClientException, SQLException {
Connection con = null;
String connectionString = "jdbc:clickhouse://localhost:8123/bank";
try {
con = DriverManager.getConnection(connectionString);
} catch (SQLException throwables) {
throwables.printStackTrace();
String query = "INSERT INTO bank.test (numero,palavra) VALUES (3,'girassol');";
Statement stmt = con.createStatement();
con.setAutoCommit(false);
try {
stmt.addBatch(query);
stmt.addBatch(query);
stmt.executeBatch();
con.commit()
}catch (Exception e)
{
e.printStackTrace();
}
con.close();
}
The stmt.executeBatch();
returns 0 elements and nothing is inserted onto the clickhouse server. I tested the same code on a Postgres DB just by replacing the connectionstring and it worked as expected.
Is there any configuration that I am missing on clickhouse?