ClickHouse-Native-JDBC icon indicating copy to clipboard operation
ClickHouse-Native-JDBC copied to clipboard

how to ignore some error rows when batch insert

Open lphu opened this issue 3 years ago • 3 comments

Environment

  • OS version: mac lastest
  • JDK version: jdk 8
  • ClickHouse Server version: lastest
  • ClickHouse Native JDBC version: lastest

when i insert batch rows, it will just throw exception if there is error type rows.

example: a data comlumn type is FixedString(3), but one row's column size over 3 and the others is ok. native jdbc will just thorw exception.

there is some solution to ignore the error row in native jdbc? or it needs myself to catch exception and record index, then skip the error rows manually?

lphu avatar Sep 02 '21 10:09 lphu

I'm afraid not, you must handle the size check before you call execute

sundy-li avatar Sep 02 '21 11:09 sundy-li

I'm afraid not, you must handle the size check before you call execute

Of course i can check every column, but is it the meaningful to add api like statement.addBatchIgnoreRows(). Just let native-jdbc skip error row, since the memroy have every column type

lphu avatar Sep 02 '21 11:09 lphu

But statement.addBatchIgnoreRows() is not standard JDBC way, because statement is an interface.

https://docs.oracle.com/javase/7/docs/api/java/sql/PreparedStatement.html

sundy-li avatar Sep 02 '21 12:09 sundy-li