does DriverManager in server side useless in the cloud 2gen SQL?

24 views
Skip to first unread message

Guy Dviri

unread,
Mar 26, 2018, 9:06:41 AM3/26/18
to Google Cloud SQL discuss
Hey ,I using android studio with java calling an app-engine endpoints  within the app ,and  in the endpoint I need to call my cloud SQL 2gen and return the result back to the app.

In the 1gen i used DriverManager in the server side , I also placing the ( User,Pass) within the DriverManager.

now I a little puzzled about the new way to combine the 2gen SQL with my appengine server side and my app.

in this tutorial i see that i need to fill ( user, pass ) in the pom.xml and in the appengine-web.xml ?  , is there's any one who can makes it more clear  to me about the process , maybe there's a code sample?

thanks.







Jordan (Cloud Platform Support)

unread,
Mar 26, 2018, 2:00:43 PM3/26/18
to google-cloud...@googlegroups.com
You only need to configure your pom.xml as shown in the Setting Up step. 

Your appengine-web.xml simply sets two properties 'cloudsql' and 'cloudsql-local' to equal the URLs of your production and local sql instances automatically using the '${xyz}' values which it directly pulls from your pom.xml and populates them to form the URLs as shown in the example code

You can now use those auto-generated property values to determine which URL your code should connect to depending on if you are running locally in development or in production (for example using this Java ternary expression):

String url = hostname.contains("localhost:") ? System.getProperty("cloudsql-local") : System.getProperty("cloudsql");

- Note that Google Groups are reserved for general product discussions and are not for technical support. If you require further technical support for connecting to your Cloud SQL instance it is recommended to post your full detailed questions to Stack Overflow using the supported Cloud tags. 
Reply all
Reply to author
Forward
0 new messages