Skip to content

Commit

Permalink
Run local w/o proxy (#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
lesv authored and dpebot committed Dec 14, 2016
1 parent b8d6110 commit bd6ee3c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
5 changes: 2 additions & 3 deletions appengine/cloudsql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <instance> --user=root`)
4. Note the **Instance connection name** under Overview > properties
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions appengine/cloudsql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<artifactId>mysql-connector-java</artifactId>
<version>5.1.40</version> <!-- v5.x.x is Java 7, v6.x.x is Java 8 -->
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
<version>1.0.2</version>
</dependency>
<!-- [END dependencies] -->
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<use-google-connector-j>true</use-google-connector-j>
<system-properties>
<property name="ae-cloudsql.cloudsql-database-url" value="jdbc:google:mysql://${INSTANCE_CONNECTION_NAME}/${database}?user=${user}&amp;password=${password}" />
<property name="ae-cloudsql.local-database-url" value="jdbc:mysql://localhost/${database}?user=${user}&amp;PASSWORD=${password}&amp;useSSL=false" />
<property name="ae-cloudsql.local-database-url" value="jdbc:mysql://google/${database}?cloudSqlInstance=${INSTANCE_CONNECTION_NAME}&amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory&amp;user=${user}&amp;password=${password}&amp;useSSL=false" />
</system-properties>
</appengine-web-app>
<!-- [END config] -->

0 comments on commit bd6ee3c

Please sign in to comment.