Search code examples
postgresqljdbcapache-kafka-connect

kafka-connect JDBC PostgreSQL Sink Connector explicitly define the PostgrSQL schema (namespace)


I am using the JDBC sink connector to write data to postgresql.

The connector works fine, but it seems the connector can only write data to the default postgresql schema called public

This is the common JDBC URL format for postgresql.

jdbc:postgresql://<host>:<port5432>/<database>

Is it possible to explicitly define the schema name, to which I need the postgresql sink connector to write?

UPDATE:

Thanks, @Laurenz Albe for the hint. I can define search_path in the jdbc connection URL like either of these:

jdbc:postgresql://<host>:<port>/<database>?options=-c%20search_path=myschema,public

jdbc:postgresql://<host>:<port>/<database>?currentSchema=myschema


Solution

  • Use the options connection parameter to set the search_path:

    jdbc:postgresql://<host>:<port5432>/<database>?options=-c%20search_path=myschema,public