# Problem with JDBC Source Connector and a hyphen in the table name

**URL:** <https://forum.confluent.io/t/problem-with-jdbc-source-connector-and-a-hyphen-in-the-table-name/1886>\
**Category:** Kafka Connect\
**Created:** [26 May 2021 10:58 UTC](https://forum.confluent.io/t/problem-with-jdbc-source-connector-and-a-hyphen-in-the-table-name/1886 "2021-05-26T10:58:19Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcelG](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@MarcelG](https://forum.confluent.io/u/MarcelG)\
**Post date:** [26 May 2021 10:58 UTC](https://forum.confluent.io/t/problem-with-jdbc-source-connector-and-a-hyphen-in-the-table-name/1886/1 "2021-05-26T10:58:19Z")

</div>

I want to put Data from a MS-SQl Table with the jdbc source connector to kafka.  
The data fromat should be avro. The problem ist my table have hyphen in the name.  
The avro Convert try to register the schema and use the table name for the avor schema name, but it is not allowed to use a hypen at the avro schema name.

Table name: `test-1`  
Avro:

```auto
 type:"record",
 name:"test-1" , < = not allowed
 fields: .....

```

It is not an option to change the table name.  
Can someone help me?

Thx  
Marcel

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [26 May 2021 11:15 UTC](https://forum.confluent.io/t/problem-with-jdbc-source-connector-and-a-hyphen-in-the-table-name/1886/2 "2021-05-26T11:15:43Z")

</div>

Use the `RegExRouter` Single Message Transform to change the topic name

e.g.

```auto
"transforms" : "dropHyphen",
"transforms.dropHyphen.type" : "org.apache.kafka.connect.transforms.RegexRouter",
"transforms.dropHyphen.regex" : "test-1",
"transforms.dropHyphen.replacement" : "test1"

```

> **[🎄 Twelve Days of SMT 🎄 - Day 4: RegExRouter](https://rmoff.net/2020/12/11/twelve-days-of-smt-day-4-regexrouter/)**

---

<div class="post-metadata">

**Author:** ![MarcelG](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@MarcelG](https://forum.confluent.io/u/MarcelG)\
**Post date:** [26 May 2021 11:46 UTC](https://forum.confluent.io/t/problem-with-jdbc-source-connector-and-a-hyphen-in-the-table-name/1886/3 "2021-05-26T11:46:30Z")

</div>

The problem is in my opinion not the topic name.  
The problem is the table name.  
Your solution only remove the hyphen in the topic name,  
but i already remove the table name in the topic name with this:

```auto
"topic": "test_topic-"
"transforms":"dropPrefix",			
    "transforms.dropPrefix.type":"org.apache.kafka.connect.transforms.RegexRouter",
    "transforms.dropPrefix.regex":"(.*)-(.*)",
    "transforms.dropPrefix.replacement":"$1"

```

Error Message:

```auto
org.apache.avro.SchemaParseException: Illegal character in: test-1
at org.apache.avro.Schema.validateName(Schema.java:1530)
at org.apache.avro.Schema.access$400(Schema.java:87)
at org.apache.avro.Schema$Name.<init>(Schema.java:673)
at org.apache.avro.Schema.createRecord(Schema.java:212)
at io.confluent.connect.avro.AvroData.fromConnectSchema(AvroData.java:867)
at io.confluent.connect.avro.AvroData.fromConnectSchema(AvroData.java:706)
at io.confluent.connect.avro.AvroData.fromConnectSchema(AvroData.java:700)

```

---

<div class="post-metadata">

**Author:** ![MarcelG](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@MarcelG](https://forum.confluent.io/u/MarcelG)\
**Post date:** [27 May 2021 12:57 UTC](https://forum.confluent.io/t/problem-with-jdbc-source-connector-and-a-hyphen-in-the-table-name/1886/4 "2021-05-27T12:57:52Z")

</div>

Hi @rmoff,

i find the correct solution for my problem.  
I use this:

```auto
"transforms":"SetSchemaName",
"transforms.SetSchemaName.type":"org.apache.kafka.connect.transforms.SetSchemaMetadata$Value",
"transforms.SetSchemaName.schema.name":"test1"

```

---

<div class="post-metadata">

**Author:** ![rmoff](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/rmoff/32/3_2.png) [@rmoff](https://forum.confluent.io/u/rmoff)\
**Post date:** [27 May 2021 13:43 UTC](https://forum.confluent.io/t/problem-with-jdbc-source-connector-and-a-hyphen-in-the-table-name/1886/5 "2021-05-27T13:43:01Z")

</div>

Great - glad you got it sorted! 👍

---

<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:** [3 June 2021 13:43 UTC](https://forum.confluent.io/t/problem-with-jdbc-source-connector-and-a-hyphen-in-the-table-name/1886/6 "2021-06-03T13:43:49Z")

</div>

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