Skip to content

Latest commit

 

History

History

druid

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

README.md

Connecting Java and Apache Druid with ADBC

Instructions

Tip

If you already have a Druid instance running, skip the steps to set up Druid.

Prerequisites

  1. Install Maven

  2. Install dbc

Set up Druid

  1. Install Docker

  2. Start a Druid 37 nano-quickstart instance:

    docker run --detach --rm \
      --name druid \
      --platform linux/amd64 \
      --publish 8888:8888 \
      --volume "$PWD/start-druid.sh:/opt/druid/start-druid.sh:ro" \
      --entrypoint /bin/bash \
      apache/druid:37.0.0 /opt/druid/start-druid.sh
  3. Wait for Druid to accept SQL queries:

    until curl --fail --silent --output /dev/null \
      --header 'Content-Type: application/json' \
      --data '{"query":"SELECT 1"}' \
      http://localhost:8888/druid/v2/sql; do sleep 2; done

Connect to Druid

  1. Install the Druid ADBC driver:

    dbc install --pre druid
  2. Customize the main method in Example.java

    • Change the connection arguments in the params.put() calls
  3. Run the Java program:

    mvn compile exec:exec

Clean up

  1. Stop the Docker container running Druid:

    docker stop druid