Skip to content

Latest commit

 

History

History
 
 

connect-jdbc-oracle12-sink

JDBC Oracle 12 Sink connector

asciinema

Objective

Quickly test JDBC Sink connector with Oracle 12.

  • Download Oracle Database 12.2.0.1 JDBC Driver ojdbc8.jarfrom this page and place it in ./ojdbc8.jar
  • Download Oracle Database 12c Release 2 (12.2.0.1.0) for Linux x86-64 linuxx64_12201_database.zipfrom this page and place it in ./linuxx64_12201_database.zip

Note: The first time you'll run the script, it will build (using this project) the docker image oracle/database:12.2.0.1-ee. It takes about 20 minutes.

Please make sure to increase Docker disk image size (96Gb is known to be working):

Docker image disk

How to run

Simply run:

$ ./oracle12-sink.sh

Details of what the script is doing

Build oracle/database:12.2.0.1-ee Docker image if required.

Wait (up to 15 minutes) that Oracle DB is up

Create the source connector with:

$ docker exec connect \
     curl -X PUT \
     -H "Content-Type: application/json" \
     --data '{
               "connector.class": "io.confluent.connect.jdbc.JdbcSinkConnector",
                    "tasks.max": "1",
                    "connection.user": "myuser",
                    "connection.password": "mypassword",
                    "connection.url": "jdbc:oracle:thin:@oracle:1521/ORCLPDB1",
                    "topics": "ORDERS",
                    "auto.create": "true",
                    "insert.mode":"insert",
                    "auto.evolve":"true"
          }' \
     http://localhost:8083/connectors/oracle-sink/config | jq .

Sending messages to topic ORDERS:

$ docker exec -i connect kafka-avro-console-producer --broker-list broker:9092 --property schema.registry.url=http://schema-registry:8081 --topic ORDERS --property value.schema='{"type":"record","name":"myrecord","fields":[{"name":"id","type":"int"},{"name":"product", "type": "string"}, {"name":"quantity", "type": "int"}, {"name":"price",
"type": "float"}]}' << EOF
{"id": 999, "product": "foo", "quantity": 100, "price": 50}
EOF

Show content of ORDERS table:

$ docker exec oracle bash -c "echo 'select * from ORDERS;' | sqlplus myuser/mypassword@//localhost:1521/ORCLPDB1"

Results:

SQL>
product
--------------------------------------------------------------------------------
  quantity      price         id
---------- ---------- ----------
foo
       100   5.0E+001        999

N.B: Control Center is reachable at http://127.0.0.1:9021