Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mvm cloud sql sample for local run #278

Merged
merged 1 commit into from
Jul 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions managed_vms/cloudsql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Before you can run or deploy the sample, you will need to do the following:
1. Set the connection string environment variable in src/main/appengine/app.yaml

## Running locally
Export local variables
$ export SQL_URL="jdbc:mysql://google/YOUR-DB-NAME?cloudSqlInstance=YOUR-INSTANCE-NAME&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=USERNAME&password=PASSWORD"
$ mvn clean jetty:run

## Deploying
Expand Down
5 changes: 0 additions & 5 deletions managed_vms/cloudsql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ Copyright 2016 Google Inc. All Rights Reserved.
<scope>provided</scope>
</dependency>
<!-- [START dependencies] -->
<dependency> <!-- http://dev.mysql.com/doc/connector-j/en/ -->
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.3</version>
</dependency>
<dependency>
<groupId>com.google.cloud.sql</groupId>
<artifactId>mysql-socket-factory</artifactId>
Expand Down
3 changes: 1 addition & 2 deletions managed_vms/cloudsql/src/main/appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,5 @@ handlers:

# [START env_variables]
env_variables:
SQL_REMOTE_URL: jdbc:mysql://google/YOUR-DB-NAME?cloudSqlInstance=YOUR-INSTANCE-NAME&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=USERNAME&password=PASSWORD
SQL_LOCAL_URL: jdbc:mysql://localhost/YOUR-DB-NAME?user=YOUR-USERNAME&password=PASSWORD&useSSL=false
SQL_URL: jdbc:mysql://google/YOUR-DB-NAME?cloudSqlInstance=YOUR-INSTANCE-NAME&socketFactory=com.google.cloud.sql.mysql.SocketFactory&user=USERNAME&password=PASSWORD
# [END env_variables]
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOExc
PrintWriter out = resp.getWriter();
resp.setContentType("text/plain");
// Detect if running remotely or locally and select correct connection url
String url;
if (System.getenv().containsKey("GAE_MODULE_INSTANCE")) {
url = System.getenv("SQL_REMOTE_URL");
} else {
url = System.getenv("SQL_LOCAL_URL");
}
String url = System.getenv("SQL_URL");

try (Connection conn = DriverManager.getConnection(url);
PreparedStatement statementCreateVisit = conn.prepareStatement(createVisitSql)) {
Expand Down