JDBC Sink Connector: Replicating into the New Database
|
This content was generated with the assistance of AI and should be verified against the official documentation before being relied on in production. |
The Debezium JDBC sink connector is the tool that turns a stream of change events back into rows. It is a Kafka
Connect sink connector: it reads the topics that a Debezium source connector fills, and for each event it runs an
INSERT, UPDATE, upsert or DELETE against a relational database through JDBC. During a migration it covers every
legacy table that keeps its shape in the new database, or that you want to copy 1:1 into a staging area, with
configuration only and no application code. Tables whose model changes (a single AUTHOR_ID that becomes a
many-to-many book_author table, numeric status codes that become enums, NUMBER keys that become uuid keys) need
a translator instead, which is the job of
Listening to Events in Applications.
This page explains how the connector applies events, why upserts make it safe under at-least-once delivery, how it
names tables and columns, how it handles deletes, schema changes, errors and data types, and documents every property
of the official property list. The running example is the bookshop-pg-mirror-sink connector of the Bookshop
migration, which copies the legacy Oracle tables BOOKSHOP.BOOK, BOOKSHOP.AUTHOR and BOOKSHOP.SUPPLIER_CATALOGUE
into the PostgreSQL mirror tables legacy_book, legacy_author and legacy_supplier_catalogue, and the
bookshop-oracle-reverse-sink connector that writes changes back to Oracle after the cut-over.
Checked on 2026-11-09 against Debezium 3.7.1.Final (JDBC sink connector plug-in debezium-connector-jdbc
3.7.1.Final, bundled with Hibernate ORM 7.4.10.Final), Apache Kafka 4.3 (Kafka Connect), Oracle AI Database 26ai
Free (image gvenzl/oracle-free:23.26.3) and PostgreSQL 18. The configuration on this page is derived from the
official documentation, and the connector class names, default values and naming behaviour were checked against the
classes in the 3.7.1.Final plug-in archive. The connectors on this page were not run as shown here; the
Worked Example: Oracle to PostgreSQL runs the
complete pipeline with the same mirror sink settings, and the stringtype=unspecified and schema requirements below
come from that run on 2026-11-09.
Where the JDBC sink fits in the migration
The legacy migration path explains why change data capture, rather than dual writes, keeps the legacy and the new database in sync while both systems run. Inside that pipeline there are two ways to apply a change event to the new database:
-
A sink connector (this page) copies a table as it is. It is the right choice for reference data and feeds that keep their shape (
AUTHOR,SUPPLIER_CATALOGUE), for a staging copy of a table that the new application reads while its own model is not ready (BOOKintolegacy_book), and for reverse replication after the cut-over. -
An application consumer (the anti-corruption layer) translates the legacy model into the new one. In Bookshop,
LegacyBookTranslator,LegacyCustomerTranslatorandLegacyOrderProjectordo this.
The two are often combined: the sink keeps a faithful mirror of the legacy table in the new database, and the translators read from the same topics to build the remodelled tables. A mirror table also helps during verification, because you can compare the legacy table with its mirror using plain SQL in a single database.
How the connector works
The connector runs inside the Kafka Connect runtime (see Kafka Connect). Each task polls the topics it is assigned, groups records into batches, resolves the destination table for each record, and writes the batch through a Hibernate-managed JDBC connection pool. The connector supports the CockroachDB, Db2, MySQL (and MariaDB), Oracle, PostgreSQL, SingleStore, SQL Server and StarRocks dialects; the 3.7 release page also lists Db2 for IBM i among the tested JDBC sink targets.
Native Debezium envelopes, no flattening needed
A Debezium source connector produces a hierarchical event with before, after, source and op fields (see
Anatomy of a Change Event). Most third-party JDBC sinks need the
event flattening SMT (ExtractNewRecordState) to turn that envelope into
a flat row first. The Debezium JDBC sink does not: it recognises the envelope and takes the column values from the
after section of a create, read (snapshot) or update event. For a delete event it does not look at the payload at all;
it deletes by the primary key that it resolves from the record (see Primary keys). It also accepts flat records,
which is how the reverse sink at the end of this page works.
To recognise the envelope, the sink needs the record schema. With the JSON converter that means
key.converter.schemas.enable=true and value.converter.schemas.enable=true on the source connector (the Kafka
Connect default), or a registry-backed format such as Avro. When the source writes schemaless JSON, the sink stays
RUNNING, writes nothing and logs "Ignore this record because it isn’t a Debezium record" for every record. The
Bookshop source therefore keeps schemas embedded, and the application consumers read the payload part (see
Listening to Events in Applications).
Keeping the envelope has two benefits for a migration. The source block stays available, so the connector can build
the table name from ${source.table} (see Table names and case sensitivity), and the same topic can feed both the
sink and the application translators without a second, flattened copy of the stream.
The sink is not designed to read schema change topics. The Oracle source connector writes DDL events to a topic named
after its topic.prefix (legacy) when include.schema.changes is enabled, so list the data topics explicitly in
topics, or write a topics.regex that cannot match the schema change topic, the
legacy.schema-history topic or the heartbeat topics.
At-least-once delivery
The connector guarantees that every event in its topics is processed at least once. It commits the consumer offsets only after the database transaction for a batch has committed, so a crash, a task restart or a consumer group rebalance between the database commit and the offset commit makes the connector read some events again. It does not offer exactly-once delivery into the database; Offsets, Restarts & Exactly-Once explains why, and Kafka reliability and exactly-once covers the Kafka side.
The answer is to make every write idempotent, so that applying the same event twice leaves the same row as applying it once:
With insert.mode=insert the second write fails with a primary key violation and the task stops (or, with a
dead-letter queue, the event is diverted although nothing was wrong with it). With insert.mode=upsert it is a
harmless overwrite. Use upsert for every migration sink.
Idempotent writes and upsert syntax
An upsert inserts the row when its primary key does not exist and updates it when it does. There is no SQL standard for this, so each dialect uses its own statement, and the dialects differ in which constraint triggers the update:
| Dialect | Upsert statement | Constraint that triggers the update |
|---|---|---|
PostgreSQL, CockroachDB |
|
The configured primary key only |
Oracle, SQL Server, Db2 |
|
The configured primary key only |
MySQL, MariaDB, SingleStore |
|
Any unique index |
StarRocks |
A plain |
The table primary key |
Two consequences matter for a migration:
-
Avoid secondary unique constraints on mirror tables. Kafka orders events only within a partition, and the connector batches and reduces by primary key only. A
UNIQUE (isbn)onlegacy_bookcan then make two valid legacy changes (book 1001 gives up an ISBN, book 1002 takes it) arrive in an order that violates the constraint. On PostgreSQL, Oracle and SQL Server the write fails; on MySQL-family targets it silently updates the wrong row. Keep uniqueness rules in the source database and leave them off the mirror. If you must keep one, route dependent rows through one partition, keepuse.reduction.buffer=falseand setbatch.size=1when a batch can hold several events for a key that the destination does not define as its primary key. -
Upserts make replays safe, not reordering. Within a partition the events of one row arrive in commit order, and Debezium source connectors key events by the table primary key, so all changes of one row land in one partition. Do not repartition the topics by another field, and do not change the key with an SMT, or the sink can apply an old version of a row after a newer one.
Multiple tasks
tasks.max sets how many tasks Kafka Connect starts. Tasks share the topic partitions, so more tasks help only when
there are several topics or several partitions. Ordering is preserved per partition, so parallel tasks do not reorder
the changes of one row. A legacy topic with one partition is processed by one task whatever tasks.max says.
Installing the connector
The quay.io/debezium/connect:3.7.1.Final image already contains the JDBC sink plug-in, so the Compose stacks in this
section need no extra step. For your own Kafka Connect installation, download the JDBC sink connector plug-in archive
for 3.7.1.Final from the Debezium releases page, extract it into a directory listed in the worker’s plugin.path, and
restart the worker (see Installing Debezium).
The official deployment procedure says that the Oracle and Db2 JDBC drivers are not included and must be added by
hand. The 3.7.1.Final plug-in archive checked for this page does contain ojdbc11-23.26.1.0.0.jar next to the
PostgreSQL, MySQL, MariaDB, SQL Server, SingleStore and StarRocks drivers, but no Db2 driver. List the archive you
deploy before you rely on either statement, and add the driver JAR to the connector directory if it is missing.
curl -s http://localhost:8083/connector-plugins | jq -r '.[].class' | grep -i jdbc
# io.debezium.connector.jdbc.JdbcSinkConnector
Reference: Debezium — JDBC connector deployment
The Bookshop mirror sink
The bookshop-pg-mirror-sink connector reads the three legacy topics and keeps a mirror table for each in the
PostgreSQL bookshop database.
Prepare the mirror tables
You can let the connector create the tables (schema.evolution=basic), but for a migration it is better to create
them yourself. You choose the exact column types, the connector never runs DDL in the new database, and the tables
are part of the new database’s versioned schema (see
Evolving the Database Model). The columns are the lower-case names of the
legacy columns, and the types are the ones the legacy values belong in (bigint for NUMBER(10), numeric(10,2)
for NUMBER(10,2)), not the string type in which decimal.handling.mode=string carries them (see
Data type mappings and Numbers as strings and stringtype=unspecified). The DDL is the same as in step 2 of the
Worked Example: Oracle to PostgreSQL.
CREATE ROLE bookshop_mirror LOGIN PASSWORD 'change-me';
CREATE TABLE legacy_book (
book_id bigint PRIMARY KEY, -- NUMBER(10) -> STRING "7" (decimal.handling.mode=string)
isbn varchar(13), -- VARCHAR2(13) -> STRING
title varchar(200),
author_id bigint, -- NUMBER(10) -> STRING
price numeric(10,2), -- NUMBER(10,2) -> STRING "24.50"
currency char(3),
published timestamp, -- DATE -> io.debezium.time.Timestamp
active_flg char(1), -- 'Y' / 'N', kept as in the legacy table
supplier_id bigint,
last_upd timestamp
);
CREATE TABLE legacy_author (
author_id bigint PRIMARY KEY,
full_name varchar(200)
);
CREATE TABLE legacy_supplier_catalogue (
supplier_id bigint,
isbn varchar(13),
supplier_price numeric(10,2),
feed_ts timestamp, -- TIMESTAMP(6) -> io.debezium.time.MicroTimestamp
PRIMARY KEY (supplier_id, isbn)
);
GRANT SELECT, INSERT, UPDATE, DELETE ON legacy_book, legacy_author, legacy_supplier_catalogue TO bookshop_mirror;
Reference: Debezium — JDBC schema evolution
The mirror keeps the legacy values as they are (ACTIVE_FLG stays 'Y'/'N', PUBLISHED stays a timestamp). The
translation into book.active boolean or published_on date belongs in the anti-corruption layer, not in the
mirror. The mirror tables have no foreign keys and no secondary unique constraints, for the reasons given in
Idempotent writes and upsert syntax.
Register the connector
bookshop-pg-mirror-sink.json: the Bookshop mirror sink{
"name": "bookshop-pg-mirror-sink",
"config": {
"connector.class": "io.debezium.connector.jdbc.JdbcSinkConnector",
"tasks.max": "1",
"topics": "legacy.BOOKSHOP.BOOK,legacy.BOOKSHOP.AUTHOR,legacy.BOOKSHOP.SUPPLIER_CATALOGUE",
"connection.url": "jdbc:postgresql://postgres:5432/bookshop?stringtype=unspecified",
"connection.username": "bookshop_mirror",
"connection.password": "change-me",
"connection.pool.min_size": "1",
"connection.pool.max_size": "4",
"connection.restart.on.errors": "true",
"insert.mode": "upsert",
"primary.key.mode": "record_key",
"delete.enabled": "true",
"truncate.enabled": "false",
"schema.evolution": "none",
"collection.name.format": "legacy_${source.table}",
"quote.identifiers": "false",
"use.time.zone": "UTC",
"batch.size": "500",
"use.reduction.buffer": "true",
"flush.max.retries": "5",
"flush.retry.delay.ms": "1000",
"errors.tolerance": "none",
"errors.log.enable": "true",
"errors.log.include.messages": "false"
}
}
Reference: Debezium — JDBC connector properties
The host name postgres is the PostgreSQL service as the Connect container sees it in the Compose stack; replace it
with your database host. The password is shown in clear text to keep the example short.
Security & Data Protection shows how to load it from a
Kafka Connect configuration provider instead.
curl -s -X POST -H "Content-Type: application/json" \
--data @bookshop-pg-mirror-sink.json http://localhost:8083/connectors
curl -s http://localhost:8083/connectors/bookshop-pg-mirror-sink/status | jq
Reference: Debezium — JDBC connector configuration
What each group of settings does:
-
topicslists the three data topics explicitly, so the schema change topic and the heartbeat topics are never read. -
?stringtype=unspecifiedat the end ofconnection.urllets PostgreSQL convert the string-encoded numbers of the Bookshop source intobigintandnumericcolumns. Without it the task fails on the first batch, as explained in Numbers as strings andstringtype=unspecified. -
insert.mode=upsertwithprimary.key.mode=record_keymakes every write idempotent. The Oracle connector keys each event with a struct of the table’s primary key columns (BOOK_ID, orSUPPLIER_IDandISBN), and the connector uses those fields as the primary key, soprimary.key.fieldsis not needed. -
delete.enabled=trueturns legacy deletes (and their tombstones) intoDELETEstatements. Without it, rows deleted in Oracle stay in the mirror forever and every reconciliation report shows them as drift. -
truncate.enabled=falsekeeps aTRUNCATEin the legacy database from emptying the mirror. Turn it on only when you want the mirror to follow truncates, and when the source connector emits them. -
schema.evolution=nonebecause the tables were created by hand.validate-onlyis not possible here: the connector cannot validate tables at startup whencollection.name.formatcontains a${source.*}placeholder, and it fails to start with that combination. -
collection.name.format=legacy_${source.table}withquote.identifiers=falsegives the lower-case table names, as explained in the next section. -
use.reduction.buffer=truecollapses several changes of the same key in one batch into one write, which helps with hot rows such as a frequently repricedBOOK. It is safe here because the mirror tables have no secondary unique constraints. -
errors.tolerance=nonestops the task on the first record that cannot be written. During a migration that is usually what you want: a stopped sink is visible, while silently skipped rows are not. The dead-letter queue variant is in Error handling and dead-letter queues.
Numbers as strings and stringtype=unspecified
The bookshop-oracle-source connector uses decimal.handling.mode=string, because the application consumers need
exact decimals in plain JSON. The Oracle connector applies that mode to every NUMBER column, including the
NUMBER(10) keys: BOOK_ID, AUTHOR_ID and SUPPLIER_ID arrive as "7", and PRICE as "24.50", all with a
Kafka Connect STRING schema. The sink maps a STRING field to Types.VARCHAR and binds the value as a
character varying parameter. PostgreSQL does not cast a typed varchar parameter to bigint or numeric
implicitly, so the first upsert fails with:
ERROR: column "supplier_id" is of type bigint but expression is of type character varying
stringtype=unspecified is a PostgreSQL JDBC driver parameter, not a Debezium property. It makes the driver send
string parameters with an unspecified type, so the server infers the type from the target column and converts "7"
to bigint and "24.50" to numeric(10,2) exactly, as it would for a literal in SQL. Text columns are not affected.
After the URL is changed, restart the failed task (POST /connectors/bookshop-pg-mirror-sink/tasks/0/restart); the
records that failed are read again from the last committed offset.
The alternative is the precise default on the source: integer NUMBER columns then arrive as INT64 and decimals
as Kafka Connect Decimal, and the sink binds them with their real types without the URL parameter. That shifts the
work to the application consumers, which then have to decode Base64 Decimal values or use Avro (see
Data Types & Precision).
Verify the mirror
-- Oracle (FREEPDB1), as a user that can read BOOKSHOP
SELECT COUNT(*), SUM(PRICE) FROM BOOKSHOP.BOOK;
-- PostgreSQL (bookshop)
SELECT COUNT(*), SUM(price) FROM legacy_book;
-- PostgreSQL: the table and column names must be lower case
SELECT table_name, column_name, data_type
FROM information_schema.columns
WHERE table_name LIKE 'legacy\_%'
ORDER BY table_name, ordinal_position;
Reference: Debezium — JDBC quoting and case sensitivity
Run the comparison after the snapshot of the source connector has finished and the sink lag is close to zero. Verification & Reconciliation turns these spot checks into per-chunk checksums.
Table names and case sensitivity
How the table name is resolved
The default collection naming strategy builds the destination table name from collection.name.format (default
${topic}) with these rules:
-
Every
.in the topic name is replaced by_, and${topic}is replaced by that sanitised topic name. With the default format, topiclegacy.BOOKSHOP.BOOKbecomes tablelegacy_BOOKSHOP_BOOK. -
Every
${source.<field>}placeholder is replaced by that field of the event’ssourceblock, for example${source.schema}(BOOKSHOP) or${source.table}(BOOK). This only works for Debezium envelopes; for a flattened record the connector logs a warning and cannot resolve the name. -
Literal text in the format is kept as it is. A literal that contains a dot, such as
BOOKSHOP.AUTHOR, is split into a schema and a table name.
The Bookshop format legacy_${source.table} therefore produces legacy_BOOK, legacy_AUTHOR and
legacy_SUPPLIER_CATALOGUE. A prefix or suffix is the usual reason to change the format; the official FAQ uses
jdbc_${topic}.
To use the topic name without sanitising it, set collection.naming.strategy to
io.debezium.sink.naming.PassthroughCollectionNamingStrategy. It replaces ${topic} with the raw topic name and
ignores ${source.*} placeholders. For anything else you can implement
io.debezium.sink.naming.CollectionNamingStrategy, put the JAR next to the connector JARs, and set
collection.naming.strategy to the class name. A custom strategy also disables validate-only startup validation.
Why legacy_BOOK becomes legacy_book in PostgreSQL
The connector builds its SQL from the resolved table name and the event field names, and by default it does not
put them in double quotes. The official "Quoting and case sensitivity" section states the consequence: the case of
the destination names then depends entirely on how the target database treats unquoted identifiers, and gives the
example that a PostgreSQL target turns a topic named ORDERS into a table named orders. PostgreSQL folds unquoted
identifiers to lower case (Oracle folds them to upper case), as its own documentation on identifiers says.
So with quote.identifiers=false:
-
The connector sends
INSERT INTO legacy_BOOK (BOOK_ID, ISBN, ...) ... ON CONFLICT (BOOK_ID) .... PostgreSQL reads every unquoted name in lower case, so the statement writes to the tablelegacy_bookand its columnsbook_id,isbn, and so on. The upper-case Oracle column names map to the lower-case mirror columns without any rename. -
When the connector looks up the table metadata, the PostgreSQL dialect also lower-cases the name before it queries the catalogue (checked in the 3.7.1.Final
PostgresDatabaseDialect), so the pre-createdlegacy_bookis found. -
With
schema.evolution=basic, the connector would createlegacy_bookwith lower-case columns in the same way.
With quote.identifiers=true the connector sends "legacy_BOOK" and "BOOK_ID". PostgreSQL then creates or looks
for a mixed-case table that every later query must quote (SELECT "BOOK_ID" FROM "legacy_BOOK"), and a pre-created
legacy_book would not match. Leave quoting off for PostgreSQL targets fed by Oracle. Turn it on only when you must
keep a mixed-case or reserved name exactly as the source has it.
Some names are quoted even with quoting off, because they would otherwise be invalid. The __connect_topic,
__connect_partition and __connect_offset columns of primary.key.mode=kafka are the usual example, since some
databases do not accept an unquoted leading underscore.
Renaming tables and fields with the naming transformations
The connector ships two SMTs that change the case of names, optionally with a prefix and a suffix:
io.debezium.connector.jdbc.transforms.CollectionNameTransformation (topic names) and
io.debezium.connector.jdbc.transforms.FieldNameTransformation (field names; for a Debezium envelope only the fields
inside before and after). The styles are camel_case, snake_case, upper_case and lower_case.
| Property | Default | Description |
|---|---|---|
|
none |
Style applied to the topic name by |
|
empty |
Prefix added to the transformed topic name. |
|
empty |
Suffix added to the transformed topic name. |
|
none |
Style applied to field names by |
|
empty |
Prefix added to each transformed field name. |
|
empty |
Suffix added to each transformed field name. |
{
"transforms": "lowercase",
"transforms.lowercase.type": "io.debezium.connector.jdbc.transforms.FieldNameTransformation",
"transforms.lowercase.column.naming.style": "lower_case"
}
Reference: Debezium — JDBC naming transformations
For PostgreSQL the transformation is not needed, because unquoted names are already folded. It becomes useful when you need quoting (for a reserved word) but still want lower-case names, or when a target database is case-sensitive.
Primary keys
primary.key.mode tells the connector which columns form the primary key. The key is used to build the ON CONFLICT
or MERGE condition of an upsert, the WHERE clause of an update or delete, and the PRIMARY KEY of a table that
the connector creates.
| Mode | Primary key columns | Migration use |
|---|---|---|
|
No primary key. Upserts and deletes are impossible. |
Append-only audit copies with |
|
|
An event log table, one row per event. Not a mirror of the source rows. |
|
The fields of the record key. A primitive key needs |
The normal choice for Debezium topics, whose key is the source table’s primary key. |
|
The fields of the record value, all of them unless |
Topics without a usable key, for example from a source table without a primary key, when the value contains a natural key. |
|
The record headers (combined into a struct), all of them unless |
Keys carried in headers by an upstream producer or SMT. |
Watch out for these cases:
-
Legacy tables without a primary key. The Oracle connector then produces events with a
nullkey. Give the table a key on the source side withmessage.key.columnsin the source connector (see Oracle Connector), or userecord_valuewithprimary.key.fields. -
kafkamode withschema.evolution=basic. Some dialects map the string__connect_topiccolumn to an unbounded type (TEXT,CLOB) that cannot be part of a primary key, and table creation fails. Create the table yourself, or avoidbasicin that mode. -
Key columns of types that cannot be keys. If a key field maps to a type that the target does not allow in a primary key, list the other fields in
primary.key.fields.
Deletes and truncates
By default the connector ignores DELETE events and tombstones, so the target keeps rows that the source has
deleted. Set delete.enabled=true to delete them. Deletes are executed by primary key, so the mode must be
record_key, record_value or record_header. 3.7 allows record_value and record_header for deletes, where
earlier versions required record_key.
Debezium source connectors emit a delete event followed by a tombstone (when tombstones.on.delete is left at its
default true). With delete.enabled=true the connector handles both; the second delete of the same key finds no row
and changes nothing, which is again idempotent.
truncate.enabled=true makes the connector truncate the destination table when it receives a truncate event. The
source must emit them (for example the PostgreSQL connector, unless truncate is in its skipped.operations). The
JDBC connector cannot process the standard truncate events of the Db2 connector; for a Db2 source, truncate with
ALTER TABLE <table> ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE instead, which needs ALTER privilege on the
table.
A migration-specific risk is the soft delete. Some legacy applications never delete rows but set a flag. The mirror follows that faithfully, and it is the translator’s job to turn the flag into a real delete or an archived state in the new model.
Schema evolution
schema.evolution controls whether the connector runs DDL in the target database.
| Mode | Behaviour |
|---|---|
|
No DDL. The tables must exist with compatible columns, or the writes fail. |
|
No DDL. At startup, or when Kafka Connect assigns a topic’s partitions, the connector checks that each statically
resolvable destination table exists. It does not compare columns, types, keys, nullability or defaults. It can
resolve a literal |
|
The connector creates a missing table from the event’s key and value schemas, and adds a column ( |
What basic cannot do is exactly what happens in a legacy schema over a long migration. A widened TITLE
VARCHAR2(200) to VARCHAR2(400) is not applied, and the next long title fails with a "value too long" error. A
renamed column leaves the old column in place and adds a new one, so old rows keep their data in the old column. A new
NOT NULL column without a default cannot be added to a table that already has rows. The nullability and default of
each new column come from the field schema; if they are not what you want, create the table yourself or adjust the
schema with an SMT.
The safer approach in a migration is:
-
Create the mirror tables yourself, as part of the new database’s schema change process, and run the sink with
none(or withvalidate-onlywhen the names are static). -
Apply a legacy DDL change to the mirror first (expand), then let the legacy change happen, as described in Handling Schema Changes.
-
If you use
basicat all, setcolumn.propagate.source.typeordatatype.propagate.source.typein the source connector, so that created columns get the source length, precision and scale instead of generic types (see Column and data type propagation).
basic is still handy in a lab, or for an audit copy that only ever gains columns.
Data type mappings
The connector resolves each column type from the field’s schema in the event: first the logical type name, if there
is one, then the primitive Kafka Connect type. It maps that to a JDBC java.sql.Types code, and Hibernate turns the
code into a column type of the target dialect. The mapping matters both when the connector creates columns and when it
binds values to columns that you created.
Kafka Connect primitive types
| Primitive type | JDBC type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Kafka Connect and Debezium logical types
| Logical type | JDBC type |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
When the target has no time or timestamp type with a time zone, the mapping falls back to the type without one.
Dialect-specific logical types (io.debezium.data.Json to json/jsonb, Uuid to uuid on PostgreSQL, Xml,
Bits, Enum, Ltree, geometry types, vectors through pgvector, and so on) have their own table in the official
documentation. A Kafka Connect STRUCT without a dedicated type is serialised to JSON and stored in a native JSON
column (PostgreSQL, MySQL, SingleStore, StarRocks, CockroachDB, Oracle 21c and later) or in a large text column (Db2,
SQL Server, earlier Oracle).
The Bookshop columns end to end
| Oracle column | Bookshop event schema (decimal.handling.mode=string) |
Event schema with the precise default |
PostgreSQL mirror column |
|---|---|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
the same |
|
|
|
the same |
|
With the Bookshop settings every NUMBER column reaches the sink as a STRING and is bound as VARCHAR, which is why
the mirror sink needs stringtype=unspecified (see Numbers as strings and stringtype=unspecified). With the
precise default, an Oracle NUMBER(p,0) becomes INT8, INT16, INT32 or INT64 depending on its precision, and a
NUMBER(p,s) with a positive scale becomes a Decimal. A bare NUMBER without precision then becomes a
VariableScaleDecimal, which the sink maps to DOUBLE and therefore loses exactness; the string mode avoids that too.
The rules are explained in Data Types & Precision.
Time zones
Oracle DATE and TIMESTAMP carry no time zone. The Oracle connector emits them as the number of milliseconds or
microseconds since the epoch, treating the wall-clock value as UTC. use.time.zone (default UTC) is the time zone in
which the sink binds temporal values. Leave it at UTC for timestamp (without time zone) mirror columns, so that a
legacy PUBLISHED of 2026-11-09 10:00 arrives as 2026-11-09 10:00. If the legacy wall-clock values are really in
local time and the new model uses timestamptz (book.updated_at), convert them in the translator, where you know
which time zone the legacy application used. Do not move the conversion into use.time.zone of a mirror sink.
Values out of range
Some sources hold temporal values that the target cannot store, for example BC-era Oracle timestamps going to a MySQL
TIMESTAMP or a SQL Server datetime2. By default such a write fails. timestamp.clamp.out.of.range.values=true
replaces them with the target’s minimum or maximum timestamp, the same way that PostgreSQL infinity and -infinity
values are handled. Clamping changes the data, so enable it only when downstream consumers accept that.
Column and data type propagation
Without extra metadata the sink knows only the Connect type of a field, so basic evolution creates generic columns
(text for every string, for example). When the source connector sets column.propagate.source.type (a list of
columns) or datatype.propagate.source.type (a list of source types), each field schema carries parameters such as
__debezium.source.column.type, __debezium.source.column.length and __debezium.source.column.scale, and the sink
uses them to create, for example, varchar(13) instead of text. The benefit is largest when source and target are
the same kind of database; for Oracle to PostgreSQL it mainly preserves lengths, precision and scale.
{
"datatype.propagate.source.type": ".+\\.NUMBER,.+\\.VARCHAR2,.+\\.CHAR"
}
If a resolved type is still not what you need, create the column yourself with the type you want. The connector never changes existing columns.
Batching, the reduction buffer and dialect options
batch.size (default 500) is the number of records the connector tries to write per batch. It is capped by the
number of records one poll returns: if the worker’s consumer.max.poll.records is smaller, raise it for this
connector with consumer.override.max.poll.records (which requires a worker connector.client.config.override.policy
that allows it).
use.reduction.buffer=true merges all events of one primary key in a batch into a single write of the latest state.
It reduces the load on the target when the same rows change often. Do not enable it when the target has constraints
that link rows with different keys (secondary unique constraints), because the intermediate states it removes may be
needed to satisfy them. For PostgreSQL targets with the reduction buffer, the official documentation recommends adding
reWriteBatchedInserts=true to the JDBC URL so that the driver rewrites the batched statements.
dialect.postgres.unnest.insert.enabled=true makes the connector write a whole batch to PostgreSQL or CockroachDB as
one INSERT ... SELECT FROM UNNEST(...) statement, in insert and upsert modes. It improves throughput for large
backfills such as the initial snapshot of SUPPLIER_CATALOGUE. A batch that contains two events for the same key
then fails with "ON CONFLICT command cannot affect row a second time", so enable use.reduction.buffer with it.
{
"connection.url": "jdbc:postgresql://postgres:5432/bookshop?stringtype=unspecified&reWriteBatchedInserts=true",
"batch.size": "2000",
"consumer.override.max.poll.records": "2000",
"use.reduction.buffer": "true",
"dialect.postgres.unnest.insert.enabled": "true"
}
dialect.sqlserver.identity.insert=true wraps inserts and upserts into a SQL Server IDENTITY column with SET IDENTITY_INSERT ... ON
and OFF. Without it, writing an explicit value into an identity column fails, which matters
when the new database is SQL Server and keeps the legacy keys. dialect.postgres.postgis.schema names the schema where
PostGIS is installed (default public), and dialect.starrocks.catalog.name selects a StarRocks catalog.
flush.max.retries (default 5) and flush.retry.delay.ms (default 1000) retry a failed flush on retriable database
errors. Keep flush.retry.delay.ms * flush.max.retries below the consumer’s max.poll.interval.ms (5 minutes by
default), or the group coordinator considers the task dead and rebalances while it is still retrying.
Connections
The connector uses Hibernate with the Agroal connection pool. The pool size is per task. connection.pool.min_size
defaults to 5 and connection.pool.max_size to 32, which is more than a single-task migration sink needs; size the
pool against the target’s connection limit, counting every task of every sink.
Idle pooled connections can be closed by the database, a proxy or a firewall, and the next write then fails. Set
hibernate.agroal.idleValidation (seconds) so that the pool validates idle connections periodically, and consider
connection.restart.on.errors=true, which treats connection failures (closed sockets, timeouts) as retriable instead
of failing the task. The official documentation warns that with asynchronous primary-replica failover, retrying can
write to a node that has not received all earlier changes; for a single PostgreSQL primary this is not a concern.
{
"hibernate.agroal.idleValidation": "300"
}
Reference: Debezium — JDBC connection idle timeouts
Any other hibernate.* property is passed to Hibernate unchanged. The common case is hibernate.dialect, set to a
fully qualified dialect class (for example org.hibernate.dialect.MariaDBDialect) when Hibernate cannot detect the
target database or its version.
Error handling and dead-letter queues
Transient and non-transient failures
The connector separates two kinds of write failure:
-
Transient failures, such as a lost connection or a serialisation conflict, are retried according to
flush.max.retriesandflush.retry.delay.ms. If the retries are exhausted, the task fails. -
Non-transient failures, such as a constraint violation, a value that is too long or a missing table, fail the task by default.
Kafka Connect itself also handles failures in the converter (deserialisation) and SMT stages, before the record reaches
the connector. Those are governed only by the standard errors.* properties.
The Kafka Connect error properties
These are standard sink connector properties of Kafka Connect, set in the connector configuration:
| Property | Default | Description |
|---|---|---|
|
|
Total time in milliseconds to retry a failed converter or transformation operation. |
|
|
Maximum delay between consecutive retries. |
|
|
|
|
|
Writes each error, the failed operation and the problem record’s coordinates to the Connect log. |
|
|
Also logs the record key, value and headers. Leave it off when the data is personal. |
|
empty |
Topic that receives failed records. Empty disables the dead-letter queue. |
|
|
Replication factor of the dead-letter topic if Connect creates it. Use |
|
|
Adds |
Routing failed writes to a dead-letter queue
Since 3.7 the JDBC sink can send records that fail with a non-transient database error to the Kafka Connect errant
record reporter (KIP-610), and from there to the dead-letter queue, instead of stopping. The official documentation
ties this to the shared change event sink framework, enabled with internal.enable.sces=true; in 3.7.1.Final this
internal property defaults to false. When a batch fails with a non-transient error, the connector retries its records
one at a time, sends only the failing ones to the reporter, and continues with the rest.
{
"internal.enable.sces": "true",
"errors.tolerance": "all",
"errors.deadletterqueue.topic.name": "bookshop-pg-mirror-sink.dlq",
"errors.deadletterqueue.topic.replication.factor": "1",
"errors.deadletterqueue.context.headers.enable": "true",
"errors.log.enable": "true",
"errors.log.include.messages": "false"
}
Rules to keep in mind:
-
errors.tolerance=nonetogether with a dead-letter topic is rejected at startup, because that topic could never receive anything. -
With
errors.tolerance=all, every non-transient failure goes to the dead-letter queue, including failures caused by the environment rather than the record, such as missing privileges for a schema evolution statement. A misconfigured sink can then divert a whole table into the queue while its status staysRUNNING. Alert on theTotalNumberOfErrantRecordsmetric and on the size of the dead-letter topic. -
Use upsert mode with a dead-letter queue. In insert mode, records replayed after a restart fail with duplicate-key errors and fill the queue with records that were already applied.
-
A record in the dead-letter queue is a hole in the mirror. Fix the cause, then replay the records (for example with a small consumer that writes them back to the source topic, or by re-snapshotting the affected rows with an incremental snapshot).
docker compose exec kafka /kafka/bin/kafka-console-consumer.sh \
--bootstrap-server kafka:9092 \
--topic bookshop-pg-mirror-sink.dlq --from-beginning \
--formatter-property print.headers=true --formatter-property print.key=true
Reference: Apache Kafka — Error reporting in Connect
For a migration, start with errors.tolerance=none. A stopped sink and a clear error in the task status are easier
to handle than a slowly growing gap. Add the dead-letter queue once the pipeline is stable, and only with alerting on
it.
Monitoring
Besides the standard Kafka Connect sink task metrics (record rates, batch sizes, offset commit times) and the
consumer lag of the connector’s consumer group (connect-bookshop-pg-mirror-sink), the connector registers its own
MBean while a task runs:
debezium.jdbc:type=connector-metrics,context=sink,server=bookshop-pg-mirror-sink,task=0
Reference: Debezium — JDBC sink monitoring
| Attribute | Type | Meaning |
|---|---|---|
|
long |
Inserts applied when |
|
long |
Updates applied when |
|
long |
Upserts applied when |
|
long |
Deletes applied. |
|
long |
Truncates applied. |
|
long |
Records skipped, for example because the table name could not be resolved, deletes or truncates are disabled, or the record is a schema change event. |
|
long |
Records sent to the errant record reporter (dead-letter queue). |
|
long |
Tables created (only with |
|
long |
Tables altered (only with |
|
boolean |
Whether the task currently has a connection to the target database. |
A rising NumberOfFilteredEvents on a mirror sink usually means deletes are arriving while delete.enabled is
false, or the table name cannot be resolved. A non-zero TotalNumberOfTablesCreated on a sink that should run with
pre-created tables means schema.evolution is not what you think.
Monitoring, Logging & Tracing shows how to export these
MBeans to Prometheus.
Connector properties
The tables below cover every property in the official JDBC connector property list, grouped as the official documentation groups them.
Kafka consumer properties
| Property | Default | Description |
|---|---|---|
|
none |
Unique connector name. Registering a second connector with the same name fails. |
|
none |
|
|
|
Maximum number of tasks. |
|
none |
Comma-separated list of topics to consume. Do not combine with |
|
none |
Regular expression (a |
Connection properties
| Property | Default | Description |
|---|---|---|
|
|
Connection provider implementation. |
|
none |
JDBC URL of the target database. |
|
none |
Database user. |
|
none |
Password of the database user. |
|
|
Minimum number of connections in the pool. |
|
|
Maximum number of concurrent connections in the pool. |
|
|
Seconds an unused connection is kept before it is discarded. (3.7.1 fixed a bug that read this value as milliseconds.) |
|
|
Treats transient connection errors (closed sockets, timeouts) as retriable instead of failing the task. Can lose data with asynchronous replicas after a failover. |
Runtime properties
| Property | Default | Description |
|---|---|---|
|
|
Time zone used when binding JDBC temporal values. |
|
|
Applies |
|
|
Applies truncate events as |
|
|
|
|
|
|
|
none |
The column name for a primitive record key, or a comma-separated subset of the key, value or header fields. If unset with a struct key, |
|
|
Delimits table and column names with quotes in the generated SQL, preserving their case. |
|
|
|
|
|
Pattern for the destination table name, with |
|
|
Schema where the PostGIS extension is installed. |
|
|
Writes a batch as one |
|
|
Sets |
|
none |
StarRocks catalog to write into ( |
|
|
Records per batch, capped by the consumer’s |
|
|
Merges the events of one primary key in a batch into a single write of the latest state. |
|
empty |
Comma-separated fields of the event value to include, as |
|
empty |
Comma-separated fields of the event value to exclude, in the same form. Not with |
|
|
Retries of a failed flush on retriable errors before the task fails. |
|
|
Delay between flush retries. |
|
|
Replaces temporal values that the target cannot store with its minimum or maximum timestamp. |
field.exclude.list is the easy way to keep a column out of the mirror, for example a legacy column with personal
data that the new system must not receive: legacy.BOOKSHOP.CUSTOMER:EMAIL. It only filters what the sink writes; the
value is still in the Kafka topic, so
Security & Data Protection shows how to drop or mask it at
the source.
Extendable properties
| Property | Default | Description |
|---|---|---|
|
|
|
|
|
|
The official property table prints the default collection strategy as io.debezium.connector.jdbc.nnaming.DefaultCollectionNamingStrategy;
the class in the 3.7.1.Final archive is io.debezium.sink.naming.DefaultCollectionNamingStrategy, which matches the
"Changing how table names are resolved" section.
Hibernate pass-through properties
Any property that starts with hibernate. is passed to Hibernate unchanged. Some Hibernate settings are already
exposed as connector properties (connection.url, connection.username, the pool sizes, use.time.zone,
quote.identifiers). Use the pass-through for the rest, for example hibernate.dialect to force a dialect, or the
hibernate.agroal.* settings of the connection pool such as hibernate.agroal.idleValidation.
Error handling properties
The errors.* properties are Kafka Connect sink settings (see The Kafka Connect error properties). The
internal property internal.enable.sces (default false in 3.7.1.Final) enables the shared change event sink
framework that routes failed writes to the dead-letter queue.
Reverse direction: PostgreSQL back to Oracle
After the write cut-over the new application owns the data, and the legacy database becomes a follower that is kept
current so that you can roll back and so that legacy reports keep working.
Cut-over & Reverse Replication describes the whole
procedure, including loop prevention. The JDBC sink is the code-free way to apply the changes for tables whose shape
did not change much. author is such a table: author (id, full_name) in PostgreSQL and AUTHOR (AUTHOR_ID,
FULL_NAME) in Oracle.
The bookshop-pg-source connector (topic prefix modern) publishes the PostgreSQL changes to modern.public.author.
The reverse sink flattens the event so that it can rename id to AUTHOR_ID with the Kafka ReplaceField SMT, which
works on flat records only, and writes to the literal table name BOOKSHOP.AUTHOR:
bookshop-oracle-reverse-sink.json: PostgreSQL author back to Oracle BOOKSHOP.AUTHOR{
"name": "bookshop-oracle-reverse-sink",
"config": {
"connector.class": "io.debezium.connector.jdbc.JdbcSinkConnector",
"tasks.max": "1",
"topics": "modern.public.author",
"connection.url": "jdbc:oracle:thin:@//oracle:1521/FREEPDB1",
"connection.username": "BOOKSHOP_SYNC",
"connection.password": "change-me",
"insert.mode": "upsert",
"primary.key.mode": "record_key",
"delete.enabled": "true",
"schema.evolution": "none",
"collection.name.format": "BOOKSHOP.AUTHOR",
"quote.identifiers": "false",
"use.time.zone": "UTC",
"transforms": "unwrap,renameKey,renameValue",
"transforms.unwrap.type": "io.debezium.transforms.ExtractNewRecordState",
"transforms.unwrap.delete.tombstone.handling.mode": "tombstone",
"transforms.renameKey.type": "org.apache.kafka.connect.transforms.ReplaceField$Key",
"transforms.renameKey.renames": "id:AUTHOR_ID",
"transforms.renameValue.type": "org.apache.kafka.connect.transforms.ReplaceField$Value",
"transforms.renameValue.renames": "id:AUTHOR_ID,full_name:FULL_NAME"
}
}
Reference: Debezium — JDBC connector properties, Debezium — New record state extraction, Apache Kafka — ReplaceField
The points that differ from the forward sink:
-
Flattened records. After
ExtractNewRecordStatethesourceblock is gone, so${source.table}cannot be resolved. Each reverse sink therefore uses a literal table name and one topic. Withdelete.tombstone.handling.mode=tombstone(the default) a delete arrives as a tombstone, which the sink applies as a delete becausedelete.enabled=true. -
Case folding in the other direction. The literal
BOOKSHOP.AUTHORis split into a schema and a table, and with quoting off Oracle resolves unquoted names in upper case, so even an unrenamedfull_namewould matchFULL_NAME. The rename ofidis what really matters. -
A dedicated Oracle user.
BOOKSHOP_SYNCneeds onlySELECT,INSERT,UPDATEandDELETEon the tables it writes. Because its changes are visible in the redo log under its own name, thebookshop-oracle-sourceconnector can ignore them withlog.mining.username.exclude.list, which is one of the loop-prevention options described on the cut-over page. -
The Oracle JDBC driver must be present in the connector directory (see Installing the connector).
-
Tables whose model changed (
purchase_orderback toORDERS,bookandbook_authorback toBOOK.AUTHOR_ID) need a translating consumer, not a sink, in this direction too.
The sqlserver-to-oracle example in the debezium-examples repository shows a complete JDBC sink into Oracle, and the
unwrap-smt example shows a sink fed by flattened events.
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
Task fails with a duplicate key error after a restart |
|
Use |
Rows deleted in the legacy database remain in the mirror |
|
Set |
The connector creates |
|
Set |
Startup fails with |
|
Use |
"value too long" after a legacy column was widened |
Schema evolution never changes existing columns |
Alter the mirror column first; see Handling Schema Changes. |
"ON CONFLICT command cannot affect row a second time" |
UNNEST inserts with several events for one key in a batch |
Enable |
The task fails while reading a schema change or heartbeat topic |
|
List the data topics in |
Rebalances while the database is slow |
Flush retries longer than |
Reduce |
|
The source uses |
Add |
The task is |
The source writes JSON with |
Enable |
Decimal values lose precision |
With the |
Configure the source connector’s |
Troubleshooting & Failure Recovery covers failures of the whole pipeline.
References
-
Debezium — Debezium connector for JDBC (sections consuming complex events, at-least-once delivery, primary key handling, delete mode, idempotent writes, secondary unique constraints, schema evolution, quoting and case sensitivity, error handling and dead letter queues, table name resolution, data and type mappings, data type mappings, monitoring, connector properties, FAQ)
-
Debezium — Release series 3.7 (tested JDBC sink targets, 3.7.1 fixes)
-
debezium-examples — sqlserver-to-oracle and debezium-examples — unwrap-smt
The configuration on this page was derived from the official documentation and checked against the 3.7.1.Final plug-in archive. The mirror sink settings were run in the worked example on 2026-11-09; the reverse sink and the tuning fragments were not run.