Search code examples
apache-kafkaapache-kafka-connectmysql-8.0

Why my kafka connects to mysql8.0 always encounters problem?


When I try to connect to mysql8.0 with kafka connect,there are always a problem about my driver. The problem is no suitable driver for found

This is for a new CentOS7 plugin.path = [share/java, /root/confluent-5.2.1/share/confluent-hub-components] Under the directory of /root/confluent-5.2.1/share/confluent-hub-components, there are tow drivers:

[root@localhost confluent-hub-components]# ls
confluentinc-kafka-connect-jdbc  debezium-debezium-connector-mysql

My driver is

[root@localhost confluent-hub-components]# cd confluentinc-kafka-connect-jdbc/
[root@localhost confluentinc-kafka-connect-jdbc]# ls
assets  doc  etc  lib  manifest.json
[root@localhost confluentinc-kafka-connect-jdbc]# cd lib
[root@localhost lib]# ls
audience-annotations-0.5.0.jar  jline-0.9.94.jar  kafka-connect-jdbc-5.2.1.jar  postgresql-9.4-1206-jdbc41.jar  sqlite-jdbc-3.25.2.jar  zookeeper-3.4.13.jar
common-utils-5.2.1.jar          jtds-1.3.1.jar    netty-3.10.6.Final.jar        slf4j-api-1.7.25.jar            zkclient-0.10.jar

Here is my code

 bin/connect-standalone etc/schema-registry/connect-avro-standalone.properties etc/kafka-connect-jdbc/mysql-source.properties

mysql-source.properties:

#tasks to create:
name=jdbc-source-mysql-01
connector.class=io.confluent.connect.jdbc.JdbcSourceConnector
#tasks.max=1
# a table called 'users' will be written to the topic 'test-mysql-jdbc-users'.
connection.user=root
connection.password=root
connection.url=jdbc:mysql://localhost:3306/employees
mode=bulk
#incrementing.column.name=fdsid
topic.prefix=test-mysql-jdbc-

Error:

Invalid value java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/employees for configuration Couldn't open connection to jdbc:mysql://localhost:3306/employees

Solution

  • The MySQL driver does not ship with the Kafka Connect JDBC connector. You have to install it yourself and in the correct location.

    You need to put the relevant MySQL JDBC Driver JAR in the Kafka Connect JDBC folder before you start the Kafka Connect worker

    This post will help you out with more detail.