0

I am trying to connect to a MySQL store as a sink using the JDBC connector for Confluent 6.2 but Connect is throwing the following exception:

org.apache.kafka.connect.errors.ConnectException: java.sql.SQLException: No suitable driver found for jdbc:mysql://AAA.BBB.CCC.DDD:3306/new_employees

I've tried placing the mysql-connector-java-8.0.26.jar in a number of different folders in the Confluent installation including share/java (that's listed in the SO answer referenced link below) and share/java/kafka-connect-jdbc (had to create that folder; based on the "Yeah, trust me" comment in https://supergloo.com/kafka-connect/kafka-connect-mysql-example/ and the confluent documentation at https://docs.confluent.io/kafka-connect-jdbc/current/index.html), but Confluent doesn't seem to be looking anywhere I've placed it.

I have read through the answers at No suitable driver found for jdbc:mysql in Kafka Connect, but that is old, and the situation seems to have changed for Confluent version 6.2. I have also verified the connection string and credentials using VSCode.

Here is the connect configuration I'm using (edited for security purposes):

{
  "name": "JdbcSinkConnectorConnector",
  "config": {
    "connector.class": "io.confluent.connect.jdbc.JdbcSinkConnector",
    "topics": "emp.employees.departments, emp.employees.dept_emp, emp.employees.dept_manager, emp.employees.employees, emp.employees.salaries, emp.employees.titles",
    "connection.url": "jdbc:mysql://AAA.BBB.CCC.DDD:3306/new_employees",
    "connection.user": "XXXXXX",
    "connection.password": "YYYYYY",
    "dialect.name": "MySqlDatabaseDialect",
    "insert.mode": "upsert",
    "auto.create": "true",
    "auto.evolve": "true"
  }
}

So, the question is, where does Confluent look for the MySQL driver jar file for connecting to MySQL as a sink?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
andand
  • 17,134
  • 11
  • 53
  • 79
  • 1
    and none of hese suggestions with class path and so helped https://stackoverflow.com/questions/5556664/how-to-fix-no-suitable-driver-found-for-jdbcmysql-localhost-dbname-error-w – nbk Aug 20 '21 at 19:30
  • @nbk There was no classpath defined earlier, but confluent seemed to be able to find other .jar files without it. But, just to be sure, I created a classpath environment variable with the jar file listed and restarted confluent connect, resulting in no change. Thanks for the suggestion, though. – andand Aug 20 '21 at 19:50
  • Please clarify how/where you set the CLASSPATH variable and how you are running `connect-distributed` script – OneCricketeer Aug 23 '21 at 16:40
  • 1
    @OneCricketeer It was a CLASSPATH problem after all. Not sure exactly how I messed it up initially, but it worked when I shut down and reset Confluent (`confluent local destroy`), did an `export CLASSPATH=` and then started Confluent back up again (`confluent local services start`). Is there a way to configure Confluent to include the jar without externally setting the CLASSPATH? It seems to find the other jars just fine. – andand Aug 24 '21 at 04:50
  • 1
    I don't use the Confluent CLI, but you can look at the `kafka-run-class` script in the Kafka bin directory to see which directories are on the default classpath, then symlink/drop your JAR there – OneCricketeer Aug 24 '21 at 13:30

0 Answers0