Tip
If you already have a MySQL instance running, skip the steps to install MySQL, start it, load data, and stop it.
-
Start a MySQL instance:
docker run -d --rm --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -p 3306:3306 mysql
-
Create a table in MySQL and load data into it:
cat games.sql | docker exec -i some-mysql mysql --user=root --password=my-secret-pw
-
Install the MySQL ADBC driver:
dbc install mysql
-
Customize the
mainmethod inExample.java- Change the connection arguments in the
params.put()calls- Format
uriaccording to the DSN (Data Source Name) format used by Go-MySQL-Driver, or keep it as is to use the data included with this example
- 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 MySQL:
docker stop some-mysql