无法连接到 SQLServer Kafka Connect

Unable to connect to SQLServer Kafka Connect

我有一张 docker 图片位于此处 https://github.com/Landoop/fast-data-dev 其中包含我用于开发的所有好东西。我试图添加一个 JDBC 连接器来推送到 Kafka 主题,但是我收到了这个错误。我在 Java 中创建了一个消费者,它工作正常但是我想使用 KafkaConnect

Invalid value java.sql.SQLException: No suitable driver found for jdbc:sqlserver://servername for configuration Couldn't open connection to jdbc:sqlserver://servername

name=JdbcSourceConnector
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
connection.user=user
connection.password=password
tasks.max=1
connection.url=jdbc:sqlserver://servername
topic.prefix=test
table.whitelist=dbo.IB_WEBLOG_DUMMY_small
query=SELECT * FROM IB_WEBLOG_DUMMY_small
value.converter=org.apache.kafka.connect.json.JsonConverter
key.converter=org.apache.kafka.connect.json.JsonConverter
poll.interval.ms=5000
table.poll.interval.ms=120000
mode=bulk

我应该研究什么来解决这个问题?

您的 JDBC 驱动程序的 JAR 文件不在 Kafka Connect 的类路径中。把它放在那里,你将是 good to go:

One option is to install the JDBC driver jar alongside the connector. The packaged connector is installed in the share/java/kafka-connect-jdbc directory, relative to the installation directory. If you have installed from Debian or RPM packages, the connector will be installed in /usr/share/java/kafka-connect-jdbc. If you installed from zip or tar files, the connector will be installed in the path given above under the directory where you unzipped the Confluent Platform archive.

Alternatively, you can set the CLASSPATH variable before running connect-standalone or connect-distributed. For example:

$ CLASSPATH=/usr/local/firebird/* ./bin/connect-distributed ./config/connect-distributed.properties

或者,将所有 SQL Server JDBC JAR 文件放在 Apache Kafka 根文件夹下的 libs 目录中。但这会污染类路径,最好在生产中避免。