title: Unable to insert into cloud Google SQL through endpoints
body: <p>I have created a Maven Endpoint project and I want to connect my project with google SQL on cloud. I have already created a database on cloud and I am trying to insert into that database through my Maven Endpoint project but when I execute my Endpoint Project, I am unable to insert into the database. I am Working with Endpoints for the first time and hence I cant figure out where I am going wrong .Any help will be appreciated.</p>
  
  <p>Thank you in advance. </p>
  
  <p>The code below is my Endpoint Project code For connecting and inserting into google SQL on cloud. </p>
  
  <pre><code>package com.syncing.SuperMarket;  
  
  import com.google.api.server.spi.config.Api;
  import com.google.api.server.spi.config.ApiMethod;
  import javax.inject.Named;
  import java.sql.DriverManager; 
  import java.sql.CallableStatement;
  import java.sql.ResultSet;
  import java.sql.SQLException;
  import java.util.ArrayList;
  
  @Api(
  name = "supermarket",
  version = "v1",
  scopes = {Constants.EMAIL_SCOPE},
  clientIds = {Constants.WEB_CLIENT_ID, Constants.ANDROID_CLIENT_ID,Constants.IOS_CLIENT_ID},
  audiences = {Constants.ANDROID_AUDIENCE}
  )
  public class Sync {
    /**
     * Insert a row into cloud Google SQL Database
     * @param no_of_products
     * @param total_amt
     * @param u_id
     * @return
     */ 
        @ApiMethod(name = "insertData")
        public void getPurchaseDetails(@Named("no_of_products") int no_of_products,@Named("total_amt") int total_amt,@Named("u_id") int u_id)
        {
                try {
                    Class.forName("com.mysql.jdbc.GoogleDriver");
                    java.sql.Connection conn = DriverManager.getConnection("jdbc:google:mysql://app-id:instance-id/db_name?user=username&amp;password=password");
                    String query = "INSERT INTO purchase (no_of_products,total_amt,u_id) VALUES (?,?,?)";
                    CallableStatement stmt = conn.prepareCall(query);
                    stmt.setInt(1, no_of_products);
                    stmt.setInt(2, total_amt);
                    stmt.setInt(3, u_id);
                    stmt.execute();
                    stmt.close();
                    conn.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }      
        }
  
  }
  </code></pre>