Featured resource
2025 Tech Upskilling Playbook
Tech Upskilling Playbook

Build future-ready tech teams and hit key business milestones with seven proven plays from industry leaders.

Check it out
  • Lab
    • Libraries: If you want this lab, consider one of these libraries.
    • Cloud
Google Cloud Platform icon
Labs

Importing Data from a Database with Kafka Connect

Kafka Connect provides a framework for moving data between Kafka and other systems. Moreover, a variety of useful connectors already exist to make this process even easier for common use cases. In this hands-on lab, you will have the opportunity to use Kafka Connect to ingest data from an external database into Kafka. You will use the Java Database Connectivity (JDBC) Connector to automatically load data from a table in a PostgreSQL database into a Kafka topic.

Google Cloud Platform icon
Lab platform
Lab Info
Level
Intermediate
Last updated
Sep 20, 2025
Duration
30m

Contact sales

By filling out this form and clicking submit, you acknowledge our privacy policy.
Table of Contents
  1. Challenge

    Create a Connector to Load Data from the Database into Kafka
    1. Create a JDBC connector to load data from the PostgreSQL database.
    curl -X POST http://localhost:8083/connectors -H "Content-Type: application/json" -d '{
      "name": "jdbc_source_postgres",
      "config": {
        "connector.class": "io.confluent.connect.jdbc.JdbcSourceConnector",
        "connection.url": "jdbc:postgresql://10.0.1.102:5432/inventory",
        "connection.user": "kafka",
        "connection.password": "Kafka!",
        "topic.prefix": "postgres-",
        "mode":"timestamp",
        "timestamp.column.name": "update_ts"
      }
    }'
    
    1. List the topic. We should see a new topic called postgres-purchases.
    kafka-topics --bootstrap-server localhost:9092 --list
    
    1. Start a console consumer to read from the postgres-purchases topic:
    kafka-console-consumer --bootstrap-server localhost:9092 --topic postgres-purchases --from-beginning
    

    Note: We should see a series of records loaded from the database. Leave the consumer running so we can observe what happens when inserting a new record into the PostgreSQL table.

  2. Challenge

    Insert a New Record for a Purchase of Plums and Observe What Happens to the Topic as a Result
    1. Log in to the PostgreSQL database server.

    2. Change to the postgres user and connect to the inventory database:

    sudo -i -u postgres
    
    psql
    
    \c inventory;
    
    1. Insert a new record into the purchases table:
    insert into purchases (product, quantity, purchase_time, update_ts) VALUES ('plums', 8, current_timestamp, current_timestamp);
    

    Note: If we leave the console consumer running, we should see a new record appear in the postgres-purchases topic containing the data we just inserted.

About the author

Pluralsight Skills gives leaders confidence they have the skills needed to execute technology strategy. Technology teams can benchmark expertise across roles, speed up release cycles and build reliable, secure products. By leveraging our expert content, skill assessments and one-of-a-kind analytics, keep up with the pace of change, put the right people on the right projects and boost productivity. It's the most effective path to developing tech skills at scale.

Real skill practice before real-world application

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Learn by doing

Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.

Follow your guide

All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.

Turn time into mastery

On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.

Get started with Pluralsight