简体   繁体   中英

Kafka Connect - No suitable driver found for jdbc:postgresql://127.0.0.1:5432/postgres

I run my sink connector, also a new kafka topic is created as soon as the connector work. Until this point everything works fine. But, as soon as I enter a new value into kafka producer, it turns out the error java.sql.SQLException: No suitable driver found for jdbc:postgresql://127.0.0.1:5432/postgres .

My config files are as below:

connect-standalone.properties:

bootstrap.servers=localhost:9092
key.converter=org.apache.kafka.connect.json.JsonConverter
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter.schemas.enable=true
value.converter.schemas.enable=true
offset.storage.file.filename=/tmp/connect.offsets
offset.flush.interval.ms=10000
plugin.path=C:/Users/me/Desktop/connectors/share/java/kafka-connect-jdbc

connect-sink-postgres.properties (my sink file):

name=psql-sink-connector
connector.class=io.confluent.connect.jdbc.JdbcSinkConnector
topics=test-topic
connection.url=jdbc:postgresql://127.0.0.1:5432/postgres
connection.user=postgres
connection.password=postgres
table.name.format=test
pk.fields=id
insert.mode=insert
tasks.max=1
value.converter.schemas.enable=true
key.converter.schemas.enable=true
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter=org.apache.kafka.connect.json.JsonConverter
auto.create=true

consumer.properties:

bootstrap.servers=localhost:9092
group.id=connect-cluster

The data in test-topic:

{"schema":{"type":"struct","fields":[{"type":"int32","optional":false,"field":"id"},{"type": "string","optional":true,"field":"msg"},{"type":"string","optional":true,"field":"importance"}],"optional":false,"name":"test"},"payload":{"id":1,"msg":"test msg","importance":"test imp"}}

Also, my DB name is kafkatest and the name of the only table in the database is test . It has id (integer primary key) , msg (varchar) , importance (varchar) as fields.

Why is that error occuring?

Even though having an absolute path for drivers, kafka connect raised error in Windows. By writing the plugin.path properly and placing the drivers to the path, same kafka connect files that didn't work in Windows worked well in Linux Ubuntu 20.04.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM