diff --git a/managed_vms/cloudsql/README.md b/managed_vms/cloudsql/README.md index 651570142a2..2bba231a4db 100644 --- a/managed_vms/cloudsql/README.md +++ b/managed_vms/cloudsql/README.md @@ -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 diff --git a/managed_vms/cloudsql/pom.xml b/managed_vms/cloudsql/pom.xml index 139f5cfd199..4ab8fc7c978 100644 --- a/managed_vms/cloudsql/pom.xml +++ b/managed_vms/cloudsql/pom.xml @@ -37,11 +37,6 @@ Copyright 2016 Google Inc. All Rights Reserved. provided - - mysql - mysql-connector-java - 6.0.3 - com.google.cloud.sql mysql-socket-factory diff --git a/managed_vms/cloudsql/src/main/appengine/app.yaml b/managed_vms/cloudsql/src/main/appengine/app.yaml index 876807c5037..95fbc276f57 100644 --- a/managed_vms/cloudsql/src/main/appengine/app.yaml +++ b/managed_vms/cloudsql/src/main/appengine/app.yaml @@ -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] diff --git a/managed_vms/cloudsql/src/main/java/com/example/managedvms/cloudsql/CloudSqlServlet.java b/managed_vms/cloudsql/src/main/java/com/example/managedvms/cloudsql/CloudSqlServlet.java index 64cb9a7b737..2cfc51bf151 100644 --- a/managed_vms/cloudsql/src/main/java/com/example/managedvms/cloudsql/CloudSqlServlet.java +++ b/managed_vms/cloudsql/src/main/java/com/example/managedvms/cloudsql/CloudSqlServlet.java @@ -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)) {