| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [View Raw Code] [Original HTTPS Page] |
This sample demonstrates how to use Cloud SQL - MySQL on Google App Engine Standard.
The sample code is located in java-docs-samples/cloud-sql/mysql/servlet. This directory has the supplemental files needed to deploy to Google App Engine Standard with Java 11.
Create a 2nd Gen Cloud SQL Instance by following these instructions. Note the connection string, database user, and database password that you create.
Create a database for your application by following these instructions. Note the database name.
Create a service account with the 'Cloud SQL Client' permissions by following these instructions. Download a JSON key to use to authenticate your connection.
See Prerequisites.
Add the appengine-simple-jetty-main Main class to your classpath:
cd java-docs-samples/appengine-java11/appengine-simple-jetty-main mvn install
cd ../../cloud-sql/mysql/servlet/
mkdir src/main/appengine
cp ../../../appengine-java11/cloudsql/app.yaml src/main/appengine/CLOUD_SQL_CONNECTION_NAME: '<MY-PROJECT>:<INSTANCE-REGION>:<MY-DATABASE>'
DB_NAME: 'my_db'
DB_USER: 'my-db-user'
DB_PASS: 'my-db-pass'cp ../../../appengine-java11/cloudsql/pom.xml ./The following command will deploy the application to your Google Cloud project:
mvn clean package appengine:deploy -DskipTests
View your application:
gcloud app browse
or by visiting https://<your-project-id>.appspot.com.
| Back | FazBrowse Home | New Git URL |