Caused by: com.github.housepower.exception.ClickHouseSQLException: For input string: ""
at com.github.housepower.misc.ExceptionUtil.rethrowSQLException(ExceptionUtil.java:70)
at com.github.housepower.jdbc.statement.ClickHousePreparedInsertStatement.initBlockIfPossible(ClickHousePreparedInsertStatement.java:207)
at com.github.housepower.jdbc.statement.ClickHousePreparedInsertStatement.<init>(ClickHousePreparedInsertStatement.java:111)
at com.github.housepower.jdbc.ClickHouseConnection.prepareStatement(ClickHouseConnection.java:158)
... ...
Caused by: java.sql.SQLException: Connection is currently waiting for an insert operation, check your previous InsertStatement.
at com.github.housepower.misc.Validate.isTrue(Validate.java:41) ~[clickhouse-native-jdbc-2.6.4.jar:?]
at com.github.housepower.jdbc.ClickHouseConnection.sendQueryRequest(ClickHouseConnection.java:267) ~[clickhouse-native-jdbc-2.6.4.jar:?]
at com.github.housepower.jdbc.statement.ClickHouseStatement.lambda$executeUpdate$0(ClickHouseStatement.java:92) ~[clickhouse-native-jdbc-2.6.4.jar:?]
at com.github.housepower.misc.ExceptionUtil.rethrowSQLException(ExceptionUtil.java:76) ~[clickhouse-native-jdbc-2.6.4.jar:?]
at com.github.housepower.jdbc.statement.ClickHouseStatement.executeUpdate(ClickHouseStatement.java:75) ~[clickhouse-native-jdbc-2.6.4.jar:?]
at com.github.housepower.jdbc.statement.ClickHouseStatement.executeQuery(ClickHouseStatement.java:100) ~[clickhouse-native-jdbc-2.6.4.jar:?]
at com.github.housepower.jdbc.statement.ClickHouseStatement.execute(ClickHouseStatement.java:69) ~[clickhouse-native-jdbc-2.6.4.jar:?]
at com.github.housepower.jdbc.statement.ClickHousePreparedQueryStatement.execute(ClickHousePreparedQueryStatement.java:67) ~[clickhouse-native-jdbc-2.6.4.jar:?]
Steps to reproduce
used clickhouse-native-jdbc
execute insert sql (error sql)
execute select sql (not error sql) [execute error :Connection is currently waiting for an insert operation, check your previous InsertStatement.]
Other descriptions
When an error occurs when the insert statement is executed for the first time, the session status is not marked as available. As a result, an error is reported for all subsequent executions.
public QueryResult sendQueryRequest(final String query, ClickHouseConfig cfg) throws SQLException {
Validate.isTrue(this.state.get() == SessionState.IDLE,
"Connection is currently waiting for an insert operation, check your previous InsertStatement.");
NativeClient nativeClient = getHealthyNativeClient();
nativeClient.sendQuery(query, nativeCtx.clientCtx(), cfg.settings());
return nativeClient.receiveQuery(cfg.queryTimeout(), nativeCtx.serverCtx());
}
The state changes only here
public int sendInsertRequest(Block block) throws SQLException {
Validate.isTrue(this.state.get() == SessionState.WAITING_INSERT, "Call getSampleBlock before insert.");
NativeClient nativeClient = getNativeClient();
nativeClient.sendData(block);
nativeClient.sendData(new Block());
nativeClient.receiveEndOfStream(cfg.get().queryTimeout(), nativeCtx.serverCtx());
Validate.isTrue(this.state.compareAndSet(SessionState.WAITING_INSERT, SessionState.IDLE));
return block.rowCnt();
}
But after the error occurred, the code was not executed.
I have the same problem with datagrip queries.
test_db> select *
from test_table
[2023-01-09 10:53:27] Connection is currently waiting for an insert operation, check your previous InsertStatement.
I-I noticed someone asked a similar question before #322
Environment
Error logs
Steps to reproduce
clickhouse-native-jdbc
Other descriptions
When an error occurs when the insert statement is executed for the first time, the session status is not marked as available. As a result, an error is reported for all subsequent executions.
The state changes only here
But after the error occurred, the code was not executed. I have the same problem with datagrip queries.
I-I noticed someone asked a similar question before #322