This sample demonstrates how to use Cloud SQL on Google App Engine standard Java 11. Find more information about connecting to Cloud SQL from App Engine.
-
Download and initialize the Cloud SDK
gcloud init -
If this is your first time creating an App Engine application:
gcloud app create
-
Setup Application Default Credentials
gcloud auth application-default login -
Note the Instance connection name under Overview > properties
Edit the environment variables in the app.yaml file with your Cloud SQL credentials:
env_variables:
DB_INSTANCE: <project_id>:<instance_region>:<database_instance>
DB_DATABASE: <database_name>
DB_USER: <user_name>
DB_PASSWORD: <password>
mvn clean package appengine:deploy -Dapp.deploy.projectId=<your-project-id>