Unable to set CLASSPATH with confluent CLI : java.sql.SQLException: No suitable driver found for jdbc:oracle:thin

Viewed 267

I want to use JDBC connector on confluent. It doesnt work when I start connect with Confluent CLI.

confluent local start connect

and it gives this error:

Caused by: java.sql.SQLException: No suitable driver found for jdbc:oracle:thin:@10.10.10.10:1954/MYSERVICE

I stop connect and start manually connect-distributed or standalone it gives same error

./bin/connect-distributed etc/schema-registry/connect-avro-distributed.properties

but when I set CLASSPATH then above code is working fine and transfer data to Oracle.

export CLASSPATH=/home/my_confluent/confluent-5.4.1/share/java/kafka-connect-jdbc/ojdbc6.jar

But still I can not do same thing with connect service.

When I up my confluent connect

confluent local start connect

it gives same error.

3 Answers

The Confluent CLI uses Golang to start up scripts underneath, so that may explain why exporting Java specific variables do not work, however, given that if you export CLASSPATH=/any/path/to/jdbc-drivers/*.jar, then run any process in the same terminal process, it should inherit those variables.

confluent local start connect internally calls some exec.command("connect-distributed") function, which thereby is a Java method call that is ran through kafka-run-class.sh, which does inherit the CLASSPATH variable

The JDBC driver needs to be within the same folder as the JDBC sink connector.

So if your JDBC sink connector (kafka-connect-jdbc-5.4.1.jar) is in etc/kafka-connect-jdbc then put ojdbc6.jar in that folder.

Edit: after placing the JDBC driver here you must restart the Kafka Connect worker.

I've written up and recorded details of this whole process here: https://rmoff.dev/fix-jdbc-driver

enter image description here

Finally I found the solution after many tries.

I copied ojdbc6.jar file into /home/ersin/confluent-5.4.1/share/java/kafka/ folder and restart connect service and boom it works like a charm.

for your information

Related