This example uses GizmoSQL, a lightweight, high-performance SQL server powered by DuckDB or SQLite that supports Arrow Flight SQL.
Tip
If you already have a GizmoSQL instance running, skip the steps to set up GizmoSQL.
-
Start the GizmoSQL server:
docker run -d --rm -it --init -p 31337:31337 --name gizmosql -e DATABASE_FILENAME=adbc_quickstart.db -e TLS_ENABLED=0 -e GIZMOSQL_PASSWORD=gizmosql_password -e PRINT_QUERIES=1 -e INIT_SQL_COMMANDS='CALL dbgen(sf=0.01);' --pull always gizmodata/gizmosql:latest-slim
-
Install the Flight SQL ADBC driver:
dbc install flightsql
-
Customize the
mainmethod inExample.java- Change the connection arguments in the
params.put()callsuriis the URI of your GizmoSQL instance. The host and port will depend on your installation (the default port is 31337). The protocol scheme should begrpcorgrpc+tcpif your GizmoSQL instance is not using TLS and should begrpc+tlsotherwise.usernameandpasswordare the username and password of your GizmoSQL admin user (the one specified when starting the instance).- You can optionally use JWT token authentication with GizmoSQL server (see more here) - with username:
tokenand a password value of the JWT token contents.
- Change the connection arguments in the
-
Run the Java program:
mvn compile exec:exec
The output will look something like this:
r_regionkey r_name r_comment 0 AFRICA ar packages. regular excuses among the ironic requests cajole fluffily blithely final requests. furiously express p 1 AMERICA s are. furiously even pinto bea 2 ASIA c, special dependencies around 3 EUROPE e dolphins are furiously about the carefully 4 MIDDLE EAST foxes boost furiously along the carefully dogged tithes. slyly regular orbits according to the special epit
-
Stop and remove the Docker container running GizmoSQL:
docker stop gizmosql