This example demonstrates how to connect a Java application to a PlanetScale database using the MySQL JDBC connector.
Follow the instructions below to find and insert your PlanetScale credentials.
- In the PlanetScale dashboard, select the database you want to connect to.
- Click "Branches" and select the branch you want to connect to.
- Click "Connect".
- Select "Java" from the "Connect from" dropdown.
- If the password is blurred, click "New password".
- Copy the credentials. You won't be able to see the password again.
- Copy the contents of
java/src/main/java/com/planetscale/example/mysql.javainto your connection file. - Replace the placeholders for
HOSTNAME,DATABASE,USERNAME, andPASSWORDwith the copied values from the previous section.
Next steps
- Learn more about the PlanetScale workflow.
- Learn how to branch your PlanetScale database for development.
- Learn how to ship schema changes to production with deploy requests.