This is a very common error that people encounter when using the Kafka Connect JDBC connector:
Caused by: java.sql.SQLException: No suitable driver found for…
e.g.
Caused by: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@10.10.10.10:1954/MYSERVICE
It means that either:
-
You have specific the JDBC URL in the wrong format. Check against this useful list to make sure it’s correct.
-
The JDBC driver for your database has not been correctly made available to Kafka Connect
Check out the recording at https://rmoff.dev/fix-jdbc-driver-video
-
00:00 Introduction and background
-
01:19 Installing JDBC driver on local install
-
05:00 Determining the Kafka Connect JDBC plugin folder
-
07:16 How to find the Kafka Connect worker log
-
09:23 Viewing the data in Confluent Control Center
-
11:05 Installing JDBC driver for Kafka Connect running on Docker
-
11:50 Installing the JDBC driver at runtime vs baking an image
-
14:29 Listing installed Kafka Connect plugins
-
15:00 Creating the connector and figuring out network addresses for the database
-
16:22 Using kafkacat to view the topics and data
Follow this one weird trick to make it work:
-
Put the JDBC driver in the same folder as the Kafka Connect JDBC plugin.
-
Restart the Kafka Connect worker
Don’t muck about with CLASSPATH
, or plugin.path
, or anything else that the Interwebs might throw up. So long as the correct JDBC driver is within the same folder as the Kafka Connect plugin JAR (kafka-connect-jdbc-5.4.1.jar
), you’re sorted.
-
Search for it
find / -name kafka-connect-jdbc\*.jar
If you find more than one folder, you need to determine which plugin Kafka Connect is loading.
-
Check the Kafka Connect worker log (
grep
forjdbc
andpluginLocation
)INFO Loading plugin from: /Users/rmoff/confluent-platform/share/java/kafka-connect-jdbc (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:241) INFO Registered loader: PluginClassLoader{pluginLocation=file:/Users/rmoff/confluent-platform/share/java/kafka-connect-jdbc/} (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:264) INFO Added plugin 'io.confluent.connect.jdbc.JdbcSinkConnector' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:193) INFO Added plugin 'io.confluent.connect.jdbc.JdbcSourceConnector' (org.apache.kafka.connect.runtime.isolation.DelegatingClassLoader:193)
curl -i -X PUT http://localhost:8083/connectors/jdbc_source_oracle_01/config \
-H "Content-Type: application/json" \
-d '{
"connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
"connection.url": "jdbc:oracle:thin:@oracle:1521/ORCLPDB1",
"connection.user": "rmoff",
"connection.password": "asgard",
"mode":"bulk",
"topic.prefix":"oracle_",
"table.whitelist":"CUSTOMERS",
"poll.interval.ms" : 10000
}'