批量新增报错PSQLException: PreparedStatement can have at most 65,535 parameters.

报错信息:
org.postgresql.util.PSQLException: PreparedStatement can have at most 65,535 parameters. Please consider using arrays, or splitting the query in several ones, or using COPY. Given query has 661,068 parameters
; SQL []; PreparedStatement can have at most 65,535 parameters. Please consider using arrays, or splitting the query in several ones, or using COPY. Given query has 661,068 parameters; nested exception is org.postgresql.util.PSQLException: PreparedStatement can have at most 65,535 parameters. Please consider using arrays, or splitting the query in several ones, or using COPY. Given query has 661,068 parameters

翻译:
这个错误是因为PreparedStatement最多只能有65,535个参数。你可以尝试使用数组、将查询拆分成几个部分或者使用COPY方法来解决这个问题。

导致原因:
数据入湖,一次性批量新增一万多条数据,加不进去,报错,没想到PreparedStatement还有限制。

解决方案:
限制批量添加的条数,一次性加两千条,多执行几次。

你可能感兴趣的:(数据库,数据库,mybatis)