From bd6ee3c59092f4586976d1959388ba1b6e2445d4 Mon Sep 17 00:00:00 2001 From: Les Vogel Date: Wed, 14 Dec 2016 15:49:50 -0800 Subject: [PATCH] Run local w/o proxy (#453) --- appengine/cloudsql/README.md | 5 ++--- appengine/cloudsql/pom.xml | 5 +++++ .../java/com/example/appengine/cloudsql/CloudSqlServlet.java | 1 + appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml | 2 +- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/appengine/cloudsql/README.md b/appengine/cloudsql/README.md index 62722914cbd..99bff3b486b 100644 --- a/appengine/cloudsql/README.md +++ b/appengine/cloudsql/README.md @@ -5,7 +5,7 @@ This sample demonstrates how to use [Cloud SQL](https://cloud.google.com/sql/) o Before you can run or deploy the sample, you will need to create a [Cloud SQL instance)](https://cloud.google.com/sql/docs/create-instance) 1. Create a new user and database for the application. The easiest way to do this is via the [Google -Developers Console](https://console.developers.google.com/sql/instances). Alternatively, you can use MySQL tools such as the command line client or workbench. +Developers Console](https://console.cloud.google.com/sql/instances). Alternatively, you can use MySQL tools such as the command line client or workbench. 2. Change the root password (under Access Control) and / or create a new user / password. 3. Create a Database (under Databases) (or use MySQL with `gcloud sql connect --user=root`) 4. Note the **Instance connection name** under Overview > properties @@ -18,10 +18,9 @@ $ mvn clean appengine:deploy -DINSTANCE_CONNECTION_NAME="instanceConnectionName" -Dpassword=myPassword -Ddatabase=myDatabase ``` -Or you can update the properties in `pom.xml` and +Or you can update the properties in `pom.xml` ## Running locally -1. You will need to be running a local instance of MySQL. ```bash $ mvn clean appengine:run -Duser=root -Dpassword=myPassowrd -Ddatabase=myDatabase diff --git a/appengine/cloudsql/pom.xml b/appengine/cloudsql/pom.xml index c4e447b286b..b1d4ff5e58b 100644 --- a/appengine/cloudsql/pom.xml +++ b/appengine/cloudsql/pom.xml @@ -66,6 +66,11 @@ mysql-connector-java 5.1.40 + + com.google.cloud.sql + mysql-socket-factory + 1.0.2 + diff --git a/appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java b/appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java index b8763237dad..da3ada939cb 100644 --- a/appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java +++ b/appengine/cloudsql/src/main/java/com/example/appengine/cloudsql/CloudSqlServlet.java @@ -62,6 +62,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc final String createVisitSql = "INSERT INTO visits (user_ip, timestamp) VALUES (?, ?)"; final String selectSql = "SELECT user_ip, timestamp FROM visits ORDER BY timestamp DESC " + "LIMIT 10"; + PrintWriter out = resp.getWriter(); resp.setContentType("text/plain"); String url; diff --git a/appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml b/appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml index eb9cb1fbef2..2ca4fde21ca 100644 --- a/appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml +++ b/appengine/cloudsql/src/main/webapp/WEB-INF/appengine-web.xml @@ -17,7 +17,7 @@ true - +