Documentation

Java Flight SQL package

Apache Arrow Flight SQL for Java integrates with Java applications to query and retrieve data from Flight database servers using RPC and SQL.

Use InfluxDB 3 client libraries

We recommend using the influxdb3-java Java client library for integrating InfluxDB 3 with your Java application code.

InfluxDB 3 client libraries wrap Apache Arrow Flight clients and provide convenient methods for writing, querying, and processing data stored in InfluxDB 3 Core. Client libraries can query using SQL or InfluxQL.

Get started using the Java Flight SQL client to query InfluxDB

Write a Java class for a Flight SQL client that connects to InfluxDB 3 Core, executes an SQL query, and retrieves data stored in an InfluxDB 3 Core database.

The example uses the Apache Arrow Java implementation (org.apache.arrow) for interacting with Flight database servers like InfluxDB 3.

  • org.apache.arrow: Provides classes and methods for integrating Java applications with Apache Arrow data and protocols.
  • org.apache.arrow.flight.sql: Provides classes and methods for interacting with Flight database servers using Arrow Flight RPC and Flight SQL.
  1. Set up InfluxDB
  2. Install prerequisites
  3. Create the FlightQuery class
  4. Create a query client
  5. Execute a query
  6. Retrieve and process Arrow data

To clone or download the example application that you can run with Docker, see the InfluxCommunity/ArrowFlightClient_Query_Examples repository on GitHub.

Set up InfluxDB

To configure the application for querying InfluxDB 3 Core, you’ll need the following InfluxDB resources:

  • InfluxDB 3 Core database
  • InfluxDB 3 Core database token with read permission to the database

If you don’t already have a database token and a database, see how to set up InfluxDB. If you don’t already have data to query, see how to write data to a database.

Install prerequisites

The following uses Docker and Maven to build and run the Java application and avoid platform-specific dependency problems.

The example Dockerfile installs compatible versions of Maven and Java JDK in the Docker container, and then runs the Maven commands to download dependencies and compile the application.

Follow the instructions to download and install Docker for your system:

View the Dockerfile

View the Maven pom.xml

Create the FlightQuery class

View FlightQuery.java

  1. In your <PROJECT_ROOT>/src/main/java directory, create the com/influxdb/examples subdirectories for the com.influxdb.examples package.

  2. In the examples directory from the preceding step, create the FlightQuery.java class file. You should have the following directory structure:

    PROJECT_ROOT
    └──src
       └──main
          └──java
             └──com
                └──influxdb
                   └──examples
                      └──FlightQuery.java
  3. In FlightQuery.java:

    1. Add the package name:

      package com.influxdb.examples;
    2. Add import statements for the following packages. You’ll use classes and methods from these packages in the remaining steps:

      • org.apache.arrow.flight.auth2.BearerCredentialWriter
      • org.apache.arrow.flight.CallHeaders
      • org.apache.arrow.flight.CallStatus
      • org.apache.arrow.flight.grpc.CredentialCallOption
      • org.apache.arrow.flight.Location
      • org.apache.arrow.flight.FlightClient
      • org.apache.arrow.flight.FlightClientMiddleware
      • org.apache.arrow.flight.FlightInfo
      • org.apache.arrow.flight.FlightStream
      • org.apache.arrow.flight.sql.FlightSqlClient
      • org.apache.arrow.flight.Ticket
      • org.apache.arrow.memory.BufferAllocator
      • org.apache.arrow.memory.RootAllocator
      • org.apache.arrow.vector.VectorSchemaRoot
    3. Create a FlightQuery class.

    4. In the FlightQuery class:

      1. Define constants for server credentials.

        • DATABASE_NAME
        • HOST
        • TOKEN

        The example Dockerfile defines environment variables for these credentials.

      2. Create a main() method.

Create a query client

In the FlightQuery.main() method, do the following to create an SQL client that can connect to HOST and DATABASE_NAME:

  1. Construct a gRPC+TLS channel URI with HOST and port 443 for communicating with a gRPC server over TLS.

  2. Instantiate FlightClientMiddleware and define an event callback that inserts the following Flight request metadata header property:

    { "database": "DATABASE_NAME" }
  3. Instantiate a BufferAllocator that sets the memory allowed for the client.

  4. Create a FlightClient with the allocator and gRPC channel.

  5. Instantiate a FlightSqlClient that wraps the FlightClient instance.

Execute a query

In the FlightQuery.main method:

  1. Instantiate a CredentialCallOption with TOKEN as a bearer credential. The result is a credential object that you’ll pass in each request to the server.

  2. Define a string that contains the SQL query to execute–for example:

    String query = "SELECT * FROM home";
  3. Call the FlightSqlClient.execute method with the SQL query and the CredentialCallOption.

  4. If successful, the FlightSqlClient.execute method responds with a FlightInfo object that contains metadata and an endpoints: [...] list. Each endpoint contains the following:

    • A list of addresses where you can retrieve the data.
    • A ticket value that identifies the data to retrieve.
  5. Extract the ticket from the response.

Retrieve and process Arrow data

In the FlightQuery.main() method, do the following to retrieve the data stream described in the FlightInfo response:

  1. Call the FlightSqlClient.getStream method with the ticket and the CredentialCallOption to fetch the Arrow stream.

  2. Call the FlightStream.getRoot method to get the current vector data from the stream.

  3. Process the data and handle exceptions. The example converts the vector data into tab-separated values and prints the result to System.out.

    For more examples using Java to work with Arrow data, see the Apache Arrow Java Cookbook.

  4. Finally, close the stream and client.

Run the application

Follow these steps to build and run the application using Docker:

  1. Copy the Dockerfile and pom.xml to your project root directory.

  2. Open a terminal in your project root directory.

  3. In your terminal, run the docker build command and pass --build-arg flags for the server credentials:

    docker build \
    --build-arg DATABASE_NAME=INFLUX_DATABASE \
    --build-arg HOST=localhost:8181\
    --build-arg TOKEN=INFLUX_TOKEN \
    -t javaflight .

    The command builds a Docker image named javaflight.

  4. To run the application in a new Docker container, enter the following command:

    docker run javaflight

    The output is the query data in TSV-format.

Troubleshoot Arrow Flight requests

For the list of Arrow Flight error response codes, see the Arrow Flight RPC documentation.


Was this page helpful?

Thank you for your feedback!


InfluxDB OSS 2.9.0: API tokens are hashed by default

Stronger token security in InfluxDB OSS 2.9.0 — tokens are hashed on disk by default. Existing tokens are hashed on first startup and can’t be recovered afterward. Capture any plaintext tokens you still need before you upgrade.

View InfluxDB OSS 2.9.0 release notes

Hashed tokens authenticate exactly like unhashed tokens — clients and integrations keep working.

Also new in 2.9.0:

  • Configurable backup compression
  • Restore support for backups containing hashed tokens
  • Tighter Edge Data Replication queue validation
  • Flux upgrade
  • Compaction reliability improvements

Key enhancements in Explorer 1.9

Explorer 1.9 is now available with InfluxQL support, an AI-assisted Flux to SQL converter (beta), and new live sample data simulators.

View Explorer 1.9 release notes

Explorer 1.9 includes new features and improvements that make it easier to query, visualize, and manage data.

Highlights:

  • Flux to SQL converter (beta): Convert Flux queries to SQL with an AI-assisted converter.
  • InfluxQL support: Query data with InfluxQL in the Data Explorer and dashboards, and save and load InfluxQL queries.
  • InfluxQL visualizations: Render line and bar charts from InfluxQL results with per-tag series grouping.
  • Query error history: Review a history of query errors in the query tool.
  • Live sample data simulators: Generate continuous live sample data with new bird data and signal generator simulators.

For more details, see Explorer 1.9 release notes

InfluxDB 3.10 is now available

InfluxDB 3 Core 3.10 adds an automatic catalog format upgrade, a configurable query-concurrency limit, and processing engine improvements.

Key updates in InfluxDB 3 Core 3.10:

  • Catalog format upgrade: the on-disk catalog automatically upgrades from format v2 to v3 on first 3.10 startup. Migration is one-way—back up your catalog before upgrading.
  • --max-concurrent-queries: limit concurrent queries (adjustable at runtime).
  • GET /ready endpoint for readiness probes.
  • Processing engine: cross-database queries and trigger lockdown flags.

For more information, see the InfluxDB 3 Core release notes.

InfluxDB 3.10 is now available

InfluxDB 3 Enterprise 3.10 adds automated backup and restore, row-level deletions, and user management, with an automatic catalog format upgrade and performance preview improvements.

Key updates in InfluxDB 3 Enterprise 3.10:

  • Catalog format upgrade: the on-disk catalog automatically upgrades from format v2 to v3 on first 3.10 startup. Migration is one-way—back up your catalog before upgrading.
  • Automated backup and restore (beta)
  • Row-level deletions
  • User management (authentication and RBAC) — preview
  • Performance preview improvements

Backup and restore, row-level deletions, and the performance preview require the Enterprise storage engine upgrade (opt-in beta). Beta and preview features are subject to breaking changes and aren’t recommended for production use.

For more information, see the InfluxDB 3 Enterprise release notes

Telegraf Enterprise is now generally available

Telegraf Enterprise is now generally available, along with Telegraf Controller v1.0.

Telegraf Enterprise combines Telegraf Controller, a centralized management console for Telegraf, with official support from InfluxData. Manage configurations, monitor fleet health, and operate tens of thousands of Telegraf agents from a single system.

InfluxDB Docker latest tag changing to InfluxDB 3 Core

On September 15, 2026, the latest tag for InfluxDB Docker images will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments.

If using Docker to install and run InfluxDB, the latest tag will point to InfluxDB 3 Core. To avoid unexpected upgrades, use specific version tags in your Docker deployments. For example, if using Docker to run InfluxDB v2, replace the latest version tag with a specific version tag in your Docker pull command–for example:

docker pull influxdb:2