clickhouse-java icon indicating copy to clipboard operation
clickhouse-java copied to clipboard

PreparedStatement insert batch sql NullPointerException

Open zhang18888888888 opened this issue 3 years ago • 3 comments

issuse : batch insert data failed which contains json type driver version: <groupId>com.clickhouse</groupId> <artifactId>clickhouse-jdbc</artifactId> 0.3.2-patch11 table schema : 1666868373686 test sql: insert into test.zx1 (id, name, test) values (?, ?, ?) code: public void insert(String sql, JSONObject data) throws SQLException { PreparedStatement preparedStatement = connection.prepareStatement(sql); ClickHousePreparedStatement clickHousePreparedStatement = (ClickHousePreparedStatement) preparedStatement; clickHousePreparedStatement.setInt(1, data.getInteger("id")); clickHousePreparedStatement.setString(2, data.getJSONObject("name").toJSONString()); clickHousePreparedStatement.setInt(3, 4); clickHousePreparedStatement.addBatch(); clickHousePreparedStatement.executeBatch(); } exception:

1666868484210

zhang18888888888 avatar Oct 27 '22 11:10 zhang18888888888

Hi @zhang18888888888, which version of ClickHouse server you're using? Before ClickHouse/ClickHouse#39866 can be fixed, you may use the workaround mentioned at #1023 for dealing with JSON.

zhicwu avatar Oct 27 '22 23:10 zhicwu

Hi @zhang18888888888, which version of ClickHouse server you're using? Before ClickHouse/ClickHouse#39866 can be fixed, you may use the workaround mentioned at #1023 for dealing with JSON. i am using 22.10.1.1877.x86_64 version using String type it works well, but i need json scene and my json data has deep nesting levels

zhang18888888888 avatar Oct 28 '22 01:10 zhang18888888888

This issue has been automatically marked as stale because it has not had activity in the last year. It will be closed in 30 days if no further activity occurs. Please feel free to leave a comment if you believe the issue is still relevant. Thank you for your contributions!

github-actions[bot] avatar Jun 19 '25 00:06 github-actions[bot]

This issue has been automatically closed because it has not had any further activity in the last 30 days. Thank you for your contributions!

github-actions[bot] avatar Jul 20 '25 00:07 github-actions[bot]