首页 > 解决方案 > Apache Kafka 中的 IDENTITY_INSERT 问题 - JDBC - MSSQL

问题描述

使用 Apache Kafka 接收器连接器将数据从 SQL Server 插入/更新到 SQL Server 得到以下错误

java.sql.BatchUpdateException:当 IDENTITY_INSERT 设置为 OFF 时,无法在表“table_name”中插入标识列的显式值。在 com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeBatch(SQLServerPreparedStatement.java:2075)

源配置

name=jdbc-mssql-prod-5
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
connection.url=jdbc:sqlserver:
connection.user=
connection.password=
topic.prefix= source_topic.
mode=timestamp
table.whitelist=A,B,C
timestamp.column.name=ModifiedDateTime

connection.backoff.ms=60000
connection.attempts=300

validate.non.null= false
# enter timestamp in milliseconds 
timestamp.initial= -1

接收器配置

name=mysql-sink-prod-5
connector.class=io.confluent.connect.jdbc.JdbcSinkConnector
tasks.max=1
topics= sink_topic_a, sink_topic_b
connection.url=jdbc:sqlserver:
connection.user=
connection.password=

insert.mode=upsert
delete.enabled=true
pk.mode=record_key


errors.log.enable= true
errors.log.include.messages=true

在表中,主键列和标识列相同。

标签: sql-serverjdbcapache-kafkaapache-kafka-connect

解决方案


推荐阅读