Tip
If you already have a DuckDB Quack server instance running, skip the steps to set up DuckDB.
-
Start the DuckDB CLI:
duckdb
-
Create a table:
CREATE TABLE penguins AS FROM read_csv('https://blobs.duckdb.org/data/penguins.csv', nullstr = 'NA');
-
Start a server from the DuckDB session:
CALL quack_serve('quack:localhost');Note the
auth_tokenvalue that DuckDB prints.
-
Install the Quack ADBC driver:
dbc install quack
-
Customize the
mainmethod inExample.java- Change the
uriconnection argument in theparams.put()call- Replace
YOUR_AUTH_TOKENwith theauth_tokenprinted by DuckDB - Change the host and port if applicable
tls=falseconnects over unencrypted HTTP, which is fine for a local server. In a real environment, change it totls=trueso the driver uses verified TLS
- Replace
- If you changed which database you're connecting to, also change the SQL SELECT statement in
stmt.setSqlQuery()
- Change the
-
Run the Java program:
mvn compile exec:exec
If you started a DuckDB server, exit the DuckDB CLI:
.exit