# Cannot get JDBC SQL Server sink to work

**URL:** https://forum.confluent.io/t/cannot-get-jdbc-sql-server-sink-to-work/3500
**Category:** Kafka Connect
**Created:** [24 November 2021 03:33 UTC](https://forum.confluent.io/t/cannot-get-jdbc-sql-server-sink-to-work/3500 "2021-11-24T03:33:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Gareth](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@Gareth](https://forum.confluent.io/u/Gareth)
#### Post date: [24 November 2021 03:33 UTC](https://forum.confluent.io/t/cannot-get-jdbc-sql-server-sink-to-work/3500/1 "2021-11-24T03:33:27Z")

</div>

Please help. Total noob but dont undertstand where im going wrong.

I am having issue Steaming from SQL Server ro SQL Server.

The Debezium source is working perfectly but when trying to write to SQL Server with JDBC whatever I try It fail. At one point it did create the id in a new table in a new DB then died again.

However I set the config for key and value conversion I get errors

#source config#

```auto
{
“name”: “sourceconn1”,
“config”: {
“connector.class” : “io.debezium.connector.sqlserver.SqlServerConnector”,
“tasks.max” : “1”,
“database.hostname” : “df-dev-mssql”,
“database.port” : “1433”,
“database.user” : “sa”,
“database.password” : “P@ssw0rd1999”,
“database.dbname” : “T014_rel-colotesting”,
“table.include.list”: “cas.Cases”,
“database.server.name” : “test7”,
“database.history.kafka.bootstrap.servers” : “localhost:9092”,
“database.history.kafka.topic”: “schema-changes7”
}
}

```

#sink config#

```auto
{
“name”: “sinkconn1”,
“config”:{
“connector.class”: “io.confluent.connect.jdbc.JdbcSinkConnector”,
“tasks.max”: “1”,
“connection.url”: “jdbc:sqlserver://df-dev-mssql:1433”,
“database”:“Sink-DB”,
“connection.user”: “sa”,
“connection.password”: “P@ssw0rd1999”,
“topics”: “test7”,
“delete.enabled”:“true”,
“pk.mode”:“record_key”,
“pk.field”:“id”,
“auto.create”: “true”

```

#ditributited props#

```auto
key.converter.schemas.enable=false
value.converter.schemas.enable=false

plugin.path=/home/kafka/kafka/plugins

```

Source is pure SQL CDC

---

<div class="post-metadata">

### Author: ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)
#### Post date: [24 November 2021 06:35 UTC](https://forum.confluent.io/t/cannot-get-jdbc-sql-server-sink-to-work/3500/2 "2021-11-24T06:35:57Z")

</div>

Hi Gareth,

which errors do you get?

Best,  
Michael

---

<div class="post-metadata">

### Author: ![Gareth](https://avatars.discourse-cdn.com/v4/letter/g/ba8739/32.png) [@Gareth](https://forum.confluent.io/u/Gareth)
#### Post date: [1 December 2021 08:38 UTC](https://forum.confluent.io/t/cannot-get-jdbc-sql-server-sink-to-work/3500/3 "2021-12-01T08:38:35Z")

</div>

Hi

Thanks for the reply, a bit more research and I found I needed to flatten JSON so for referernce for anyone new to Kafka I added these to source;

```
 "transforms":"unwrap",
 "transforms.unwrap.type":"io.debezium.transforms.ExtractNewRecordState",
 "transforms.unwrap.delete.handling.mode":"none",

```

and with a few changes to sink config:

```
"delete.enabled":"true",
"insert.mode":"upsert",

```

Have insert, update and delete working perfectly.

Now to play with transforms and kSQL.

Thanks again for the support.

Gareth

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)
#### Post date: [8 December 2021 08:39 UTC](https://forum.confluent.io/t/cannot-get-jdbc-sql-server-sink-to-work/3500/4 "2021-12-08T08:39:32Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
