Tip
If you already have a Vitess instance running, skip the steps to set up and clean up Vitess.
-
Start a Vitess instance:
docker run -d --rm --name=vttestserver \ -p 33574:33574 \ -p 33575:33575 \ -p 33577:33577 \ -e PORT=33574 \ -e KEYSPACES=test,unsharded \ -e NUM_SHARDS=2,1 \ -e MYSQL_MAX_CONNECTIONS=70000 \ -e MYSQL_BIND_HOST=0.0.0.0 \ -e VTCOMBO_BIND_HOST=0.0.0.0 \ vitess/vttestserver:mysql80Wait a few moments before continuing to the next step to allow the Vitess container to fully initialize.
-
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
- 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 Vitess:
docker stop vttestserver