title: Kafka connect Jdbc sink connector not auto creating tables
body: <p>I am using docker images of kafka and kafka connect to test cdc using debezium, and the database is a standalone one</p>
  <p>My sink connector config json looks like this,</p>
  <pre><code>    {
      &quot;name&quot;: &quot;jdbc-sink-test-oracle&quot;,
      &quot;config&quot;: {
          &quot;connector.class&quot;: &quot;io.confluent.connect.jdbc.JdbcSinkConnector&quot;,
          &quot;tasks.max&quot;: &quot;1&quot;,
          &quot;dialect.name&quot;: &quot;OracleDatabaseDialect&quot;,
          &quot;table.name.format&quot;: &quot;TEST&quot;,
          &quot;topics&quot;: &quot;oracle-db-source.DBZ_SRC.TEST&quot;,
          &quot;connection.url&quot;: &quot;jdbc:oracle:thin:@hostname:1521/DB&quot;,
          &quot;connection.user&quot;: &quot;DBZ_TARGET&quot;,
          &quot;connection.password&quot;: &quot;DBZ_TARGET&quot;,
          &quot;transforms&quot;: &quot;unwrap&quot;,
          &quot;transforms.unwrap.type&quot;: &quot;io.debezium.transforms.ExtractNewRecordState&quot;,
          &quot;transforms.unwrap.drop.tombstones&quot;: &quot;false&quot;,
          &quot;value.converter&quot;: &quot;org.apache.kafka.connect.json.JsonConverter&quot;,
          &quot;value.converter.schemas.enable&quot;: &quot;true&quot;,
          &quot;auto.create&quot;: &quot;true&quot;,
          &quot;insert.mode&quot;: &quot;upsert&quot;,
          &quot;delete.enabled&quot;: &quot;true&quot;,
          &quot;pk.fields&quot;: &quot;ID&quot;,
          &quot;pk.mode&quot;: &quot;record_key&quot;
      }
  }
  </code></pre>
  <p>and my source connector config json looks like this,</p>
  <pre><code>
      {
      &quot;name&quot;: &quot;test-source-connector&quot;,
      &quot;config&quot;: {
          &quot;connector.class&quot; : &quot;io.debezium.connector.oracle.OracleConnector&quot;,
          &quot;tasks.max&quot; : &quot;1&quot;,
          &quot;database.server.name&quot; : &quot;oracle-db-source&quot;,
          &quot;database.hostname&quot; : &quot;hostname&quot;,
          &quot;database.port&quot; : &quot;1521&quot;,
          &quot;database.user&quot; : &quot;clogminer&quot;,
          &quot;database.password&quot; : &quot;clogminer&quot;,
          &quot;database.dbname&quot; : &quot;DB&quot;,
          &quot;database.oracle.version&quot;: &quot;19&quot;,
          &quot;database.history.kafka.bootstrap.servers&quot; : &quot;kafka:9092&quot;,
          &quot;database.history.kafka.topic&quot;: &quot;schema-changes.DBZ_SRC&quot;,
          &quot;database.connection.adapter&quot;: &quot;logminer&quot;,
          &quot;table.include.list&quot; : &quot;DBZ_SRC.TEST&quot;,
          &quot;database.schema&quot;: &quot;DBZ_SRC&quot;,
          &quot;errors.log.enable&quot;: &quot;true&quot;,
          &quot;snapshot.lock.timeout.ms&quot;:&quot;5000&quot;,
          &quot;include.schema.changes&quot;: &quot;true&quot;,
          &quot;snapshot.mode&quot;:&quot;initial&quot;,
          &quot;decimal.handling.mode&quot;: &quot;double&quot;
      }
  }
  </code></pre>
  <p>and I am getting this error for the above configurations,</p>
  <pre><code>    Error : 942, Position : 11, Sql = merge into &quot;TEST&quot; using (select :1  &quot;ID&quot;, :2  &quot;NAME&quot;, :3  &quot;DESCRIPTION&quot;, :4  &quot;WEIGHT&quot; FROM dual) incoming on(&quot;TEST&quot;.&quot;ID&quot;=incoming.&quot;ID&quot;) when matched then update set &quot;TEST&quot;.&quot;NAME&quot;=incoming.&quot;NAME&quot;,&quot;TEST&quot;.&quot;DESCRIPTION&quot;=incoming.&quot;DESCRIPTION&quot;,&quot;TEST&quot;.&quot;WEIGHT&quot;=incoming.&quot;WEIGHT&quot; when not matched then insert(&quot;TEST&quot;.&quot;NAME&quot;,&quot;TEST&quot;.&quot;DESCRIPTION&quot;,&quot;TEST&quot;.&quot;WEIGHT&quot;,&quot;TEST&quot;.&quot;ID&quot;) values(incoming.&quot;NAME&quot;,incoming.&quot;DESCRIPTION&quot;,incoming.&quot;WEIGHT&quot;,incoming.&quot;ID&quot;), OriginalSql = merge into &quot;TEST&quot; using (select ? &quot;ID&quot;, ? &quot;NAME&quot;, ? &quot;DESCRIPTION&quot;, ? &quot;WEIGHT&quot; FROM dual) incoming on(&quot;TEST&quot;.&quot;ID&quot;=incoming.&quot;ID&quot;) when matched then update set &quot;TEST&quot;.&quot;NAME&quot;=incoming.&quot;NAME&quot;,&quot;TEST&quot;.&quot;DESCRIPTION&quot;=incoming.&quot;DESCRIPTION&quot;,&quot;TEST&quot;.&quot;WEIGHT&quot;=incoming.&quot;WEIGHT&quot; when not matched then insert(&quot;TEST&quot;.&quot;NAME&quot;,&quot;TEST&quot;.&quot;DESCRIPTION&quot;,&quot;TEST&quot;.&quot;WEIGHT&quot;,&quot;TEST&quot;.&quot;ID&quot;) values(incoming.&quot;NAME&quot;,incoming.&quot;DESCRIPTION&quot;,incoming.&quot;WEIGHT&quot;,incoming.&quot;ID&quot;), Error Msg = ORA-00942: table or view does not exist
  
  
          at io.confluent.connect.jdbc.sink.JdbcSinkTask.getAllMessagesException(JdbcSinkTask.java:150)
          at io.confluent.connect.jdbc.sink.JdbcSinkTask.put(JdbcSinkTask.java:102)
          ... 11 more
  2022-07-28 15:01:58,644 ERROR  ||  WorkerSinkTask{id=jdbc-sink-test-oracle-0} Task threw an uncaught and unrecoverable exception. Task is being killed and will not recover until manually restarted   [org.apache.kafka.connect.runtime.WorkerTask]
  org.apache.kafka.connect.errors.ConnectException: Exiting WorkerSinkTask due to unrecoverable exception.
          at org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:610)
          at org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:330)
          at org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:232)
          at org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:201)
          at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:188)
          at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:237)
          at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
          at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
          at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
          at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
          at java.base/java.lang.Thread.run(Thread.java:829)
  Caused by: org.apache.kafka.connect.errors.ConnectException: java.sql.SQLException: Exception chain:
  java.sql.BatchUpdateException: ORA-00942: table or view does not exist
  
  java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist
  </code></pre>
  <p>I believe according to the configurations I gave, the table needs to be auto created but it says table doesnt exist.</p>
  <p>But, it is working fine and is auto creating the table named 'TEST2' and is also exporting the data from source to this table for this sink connector configuration</p>
  <pre><code>{
      &quot;name&quot;: &quot;jdbc-sink-test2-oracle&quot;,
      &quot;config&quot;: {
          &quot;connector.class&quot;: &quot;io.confluent.connect.jdbc.JdbcSinkConnector&quot;,
          &quot;tasks.max&quot;: &quot;1&quot;,
          &quot;dialect.name&quot;: &quot;OracleDatabaseDialect&quot;,
          &quot;table.name.format&quot;: &quot;TEST2&quot;,
          &quot;topics&quot;: &quot;oracle-db-source.DBZ_SRC.TEST&quot;,
          &quot;connection.url&quot;: &quot;jdbc:oracle:thin:@hostname:1521/DB&quot;,
          &quot;connection.user&quot;: &quot;DBZ_TARGET&quot;,
          &quot;connection.password&quot;: &quot;DBZ_TARGET&quot;,
          &quot;transforms&quot;: &quot;unwrap&quot;,
          &quot;transforms.unwrap.type&quot;: &quot;io.debezium.transforms.ExtractNewRecordState&quot;,
          &quot;transforms.unwrap.drop.tombstones&quot;: &quot;false&quot;,
          &quot;auto.create&quot;: &quot;true&quot;,
          &quot;insert.mode&quot;: &quot;upsert&quot;,
          &quot;delete.enabled&quot;: &quot;true&quot;,
          &quot;pk.fields&quot;: &quot;ID&quot;,
          &quot;pk.mode&quot;: &quot;record_key&quot;
      }
  }
  </code></pre>
  <p>Edit:</p>
  <p>The sink connector is working fine if the target table with the same name as the source table is already created with same DDL, but the target table is not getting auto created if it is not present already.</p>