4

I am trying to connect to Oracle database which is outside of docker container. I am new to Docker and not sure how to achieve the same. On my local machine, I can connect to specific database by providing Host, Service name and Port or just by referring entry mentioned in tnsnames.ora file. I have installed Docker on my Windows 10 machine. My ultimate goal is to stream my tables on kafka topic using ksqlDB. But, first step is to connect to my oracle database. I am not sure what modifications or setting are required to connect to any external database source from Docker. I tried below connector configuration but this is not working.

Connector configuration :

CREATE SOURCE CONNECTOR jdbc_source WITH(
'connector.class'       =   'io.confluent.connect.jdbc.JdbcSourceConnector',
'connection.url'        =   'jdbc:oracle:thin://dv11-db.com:1521/dv11.db.com',
'connection.user'       =   'user',
'connection.password'   =   'password',
'topic.prefix'          =   'jdbc_',
'mode'                  =   'bulk',
'table.whitelist'       =   'batch_driver'
);

Errors :

{
  "error_code" : 400,
  "message" : "Connector configuration is invalid and contains the following 2 error(s):\nInvalid value java.sql.SQLException: No suitable driver
found for jdbc:oracle:thin://dv11-db.com:1521/dv11.db.com for configuration Couldn't open connection to jdbc:oracle:thin://dv11-db.com:1521/dv11.db.com\nInvalid value java.sql.SQLException: No suitable driver found for jdbc:oracle:thin://dv11-db.com:1521/dv11.db.com for configuration Couldn't open connection to jdbc:oracle:thin://dv11-db.com:1521/dv11.db.com\nYou can also find the above list of errors at the endpoint `/{connectorType}/config/validate`"
}

Oracle Configuration:

(DESCRIPTION =    (ADDRESS = (PROTOCOL = TCP)(HOST = dv11-db.com)(PORT = 1521))    (CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = dv11.db.com)))

Docker-compose.yml

---
version: '2'
services:
  zookeeper:
    image: confluentinc/cp-zookeeper:latest
    hostname: zookeeper
    container_name: zookeeper
    ports:
      - "2181:2181"
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000

  broker:
    image: confluentinc/cp-enterprise-kafka:latest
    hostname: broker
    container_name: broker
    depends_on:
      - zookeeper
    ports:
      - "29092:29092"
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:9092,PLAINTEXT_HOST://localhost:29092
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
      KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0
      KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
      KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1

  ksqldb-server:
    image: confluentinc/ksqldb-server:0.7.0
    hostname: ksqldb-server
    container_name: ksqldb-server
    depends_on:
      - broker
    ports:
      - "8088:8088"
    environment:
      KSQL_LISTENERS: http://0.0.0.0:8088
      KSQL_BOOTSTRAP_SERVERS: broker:9092
      KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE: "true"
      KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE: "true"
      KSQL_KSQL_CONNECT_WORKER_CONFIG: "/connect/connect.properties"
      KSQL_CONNECT_GROUP_ID: "ksql-connect-cluster"
      KSQL_CONNECT_BOOTSTRAP_SERVERS: "broker:9092"
      KSQL_CONNECT_KEY_CONVERTER: "org.apache.kafka.connect.storage.StringConverter"
      KSQL_CONNECT_VALUE_CONVERTER: "org.apache.kafka.connect.json.JsonConverter"
      KSQL_CONNECT_VALUE_CONVERTER_SCHEMAS_ENABLE: "false"
      KSQL_CONNECT_CONFIG_STORAGE_TOPIC: "ksql-connect-configs"
      KSQL_CONNECT_OFFSET_STORAGE_TOPIC: "ksql-connect-offsets"
      KSQL_CONNECT_STATUS_STORAGE_TOPIC: "ksql-connect-statuses"
      KSQL_CONNECT_CONFIG_STORAGE_REPLICATION_FACTOR: 1
      KSQL_CONNECT_OFFSET_STORAGE_REPLICATION_FACTOR: 1
      KSQL_CONNECT_STATUS_STORAGE_REPLICATION_FACTOR: 1
      KSQL_CONNECT_PLUGIN_PATH: "/usr/share/kafka/plugins"
  volumes:
      - ./confluentinc-kafka-connect-jdbc-5.4.0:/usr/share/kafka/plugins/jdbc 

  ksqldb-cli:
    image: confluentinc/ksqldb-cli:0.7.0
    container_name: ksqldb-cli
    depends_on:
      - broker
      - ksqldb-server
    entrypoint: /bin/sh
    tty: true
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Praveenks
  • 1,436
  • 9
  • 40
  • 79

1 Answers1

2

java.sql.SQLException: No suitable driver

Not a docker problem. You've not put your database driver in the right location

It shouldn't go in /usr/share/kafka/plugins/jdbc.

It should go in /usr/share/kafka-connect-jdbc

Refer https://www.confluent.io/blog/kafka-connect-deep-dive-jdbc-source-connector/

On my local machine, I can connect to specific database by providing Host, Service name and Port or just by referring entry mentioned in tnsnames.ora file

Not clear how you're connecting... From code? From some Oracle tool?

If your database is on another server, Docker's network connection should work the exact same way. You still need to setup your drivers

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • Thanks for the response. I have edited my docker-compose.yml file as suggested. But now, I am getting below error : error_code" : 500, "message" : "Failed to find any class that implements Connector and which name matches io.confluent.connect.jdbc.JdbcSourceConnector, available connectors are: PluginDesc{klass=class org.apache.kafka.connect.tools.MockConnector, name='org.apache.kafka.connect.tools.MockConnector', version='5.5.0-ccs-beta200204173843', encodedVersion=5.5.0-ccs-beta200204173843, type=connect....etc.... } – Praveenks Mar 03 '20 at 09:28
  • Why are you using the 5.5 beta versions of things? Please don't use latest tag. Try 5.4.0 – OneCricketeer Mar 03 '20 at 14:03