title: Accessing existing cloud SQL instance from another project ID
body: <p>I have created a cloud sql instance in a PHP project and have made the billing procedure successfully. The project works.</p>
  
  <p>Now, I want to access my database from another project but this time in Java SDK project with servlets.
  Using the example in <a href="https://developers.google.com/appengine/" rel="noreferrer">https://developers.google.com/appengine/</a>
  docs/java/cloud-sql/</p>
  
  <p>In Java project I have:</p>
  
  <h2>project id:   javaProjectID</h2>
  
  <p>In php project id I have:
  project id:     phptestID
  instance name:  phpinstanceName</p>
  
  <h2>database:       dbname</h2>
  
  <p>In my code in Servlet i do the below connection:</p>
  
  <pre><code>String url = "jdbc:google:mysql://phptestID:phpinstanceName/dbname?user=root";
  Connection conn = (Connection) DriverManager.getConnection(url);
  </code></pre>
  
  <p>(...>> The connection fails in this point and doesn't access the database to make the below query )</p>
  
  <pre><code>String sqlStmt = "SELECT * FROM  sometable";
  PreparedStatement  stmt = conn.prepareStatement(sqlStmt);
  ResultSetres = stmt.executeQuery(sqlStmt);
  </code></pre>
  
  <p>How can I access my database in another project?? Is there any other way except 
  your-project-id:your-instance-name???</p>