Tip
If you already have a Spark instance running, skip the steps to set up and clean up Spark.
-
Start a Spark instance:
docker run -d --rm --name spark-connect -p 15002:15002 apache/spark:4.1.2 bash -c "/opt/spark/sbin/start-connect-server.sh && tail -f /dev/null"
-
Install the Spark ADBC driver:
dbc install spark --pre
-
Customize the
mainmethod inExample.java- Change the connection arguments in the
params.put()calls- Format
uriaccording to the driver documentation, or keep it as is
- Format
- If you changed which database you're connecting to, also change the SQL SELECT statement in
stmt.setSqlQuery()
- Change the connection arguments in the
-
Run the Java program:
mvn compile exec:exec
Stop the Docker container running Spark:
docker stop spark-connect