Monday, March 26, 2018

[google-cloud-sql-discuss] Re: does DriverManager in server side useless in the cloud 2gen SQL?

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");

--
You received this message because you are subscribed to the Google Groups "Google Cloud SQL discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-cloud-sql-discuss+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-cloud-sql-discuss/aca37ca4-2230-4e64-a8c5-e5c67f14d83a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment