Java¶
All integration guides. Flight SQL JDBC 19.0.0 is the validated Java route. Native Java Flight SDK access is untested against this server.
Install and query through JDBC¶
Follow the server and sample table setup. Install a full JDK (recorded local tests used Java 25), then download the verified driver from the repository root:
make bin/flight-sql-jdbc-driver-19.0.0.jar
For Maven applications use org.apache.arrow:flight-sql-jdbc-driver:19.0.0.
See the official driver instructions.
Save the following as FlightQuery.java:
import java.sql.*;
public class FlightQuery {
public static void main(String[] args) throws Exception {
String url = "jdbc:arrow-flight-sql://localhost:8815/?useEncryption=false";
try (Connection conn = DriverManager.getConnection(url);
PreparedStatement stmt = conn.prepareStatement(
"SELECT id, label FROM flight_tool_sample WHERE id >= ? ORDER BY id")) {
stmt.setInt(1, 2);
try (ResultSet rows = stmt.executeQuery()) {
while (rows.next()) {
System.out.println(rows.getLong(1) + ": " + rows.getString(2));
}
}
}
}
}
On Java 25, run:
java --add-opens=java.base/java.nio=ALL-UNNAMED \
--sun-misc-unsafe-memory-access=allow \
-cp bin/flight-sql-jdbc-driver-19.0.0.jar FlightQuery.java
Expect 2: null and 3: three. Java 17–22 must omit the
--sun-misc-unsafe-memory-access option; Java 23+ needs it for this setup.
Use executeUpdate for writes and verify them with a fresh SELECT. Keep
autocommit enabled and execute statements separately.
Validation and limits¶
Run make jdbc-smoke against a disposable running server. Override the address
with JDBC_URL and the JDK with JAVA=/path/to/bin/java. The smoke suite tests
metadata, prepared parameters, writes, sessions and concurrent statement/result
reads. See the JDBC caveats
for empty getTypeInfo() and prepared statements without a result schema.
For named datasets, use the native Java Flight SDK with the server's dataset API; JDBC does not expose that API. This is an unvalidated development route. Remove the shared sample table with the fixture cleanup.
Write and verify through JDBC¶
Save as FlightWrite.java and run with the same driver classpath and JVM flags
as FlightQuery.java above. This creates its own table and removes it afterward.
The live recipe run passed both Java examples
with JDBC 19.0.0 and JDK 21.
import java.sql.*;
import java.util.UUID;
public class FlightWrite {
public static void main(String[] args) throws Exception {
String name = "guide_" + UUID.randomUUID().toString().replace("-", "");
String url = "jdbc:arrow-flight-sql://localhost:8815/?useEncryption=false";
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
conn.setAutoCommit(true);
try {
stmt.executeUpdate("CREATE TABLE " + name + " (id BIGINT, amount DOUBLE)");
stmt.executeUpdate("INSERT INTO " + name + " VALUES (1, 2.5)");
try (ResultSet rows = stmt.executeQuery("SELECT * FROM " + name)) {
if (!rows.next() || rows.getLong("id") != 1 || rows.getDouble("amount") != 2.5
|| rows.next()) throw new AssertionError("write/read-back mismatch");
}
} finally {
stmt.executeUpdate("DROP TABLE IF EXISTS " + name);
}
}
}
}