Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PreparedStatement insert batch sql NullPointerException #1116

Open
zhang18888888888 opened this issue Oct 27, 2022 · 2 comments
Open

PreparedStatement insert batch sql NullPointerException #1116

zhang18888888888 opened this issue Oct 27, 2022 · 2 comments
Labels

Comments

@zhang18888888888
Copy link

issuse : batch insert data failed which contains json type
driver version:

com.clickhouse
clickhouse-jdbc
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

@zhicwu
Copy link
Contributor

zhicwu commented Oct 27, 2022

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.

@zhang18888888888
Copy link
Author

zhang18888888888 commented Oct 28, 2022

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

@chernser chernser added bug module-jdbc JDBC driver labels Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants