File tree Expand file tree Collapse file tree
src/main/java/com/example/cloudsql
postgres/servlet/src/main/java/com/example/cloudsql
sqlserver/servlet/src/main/java/com/example/cloudsql Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ for more details on connecting a Cloud Run service to Cloud SQL.
8585 --platform managed \
8686 --allow-unauthenticated \
8787 --region [REGION] \
88- --update-env-vars CLOUD_SQL_CONNECTION_NAME=[INSTANCE_CONNECTION_NAME ] \
88+ --update-env-vars CLOUD_SQL_CONNECTION_NAME=[CLOUD_SQL_CONNECTION_NAME ] \
8989 --update-env-vars DB_USER=[MY_DB_USER] \
9090 --update-env-vars DB_PASS=[MY_DB_PASS] \
9191 --update-env-vars DB_NAME=[MY_DB]
@@ -96,6 +96,7 @@ for more details on connecting a Cloud Run service to Cloud SQL.
9696
9797 Take note of the URL output at the end of the deployment process.
9898
99+
991003 . Navigate your browser to the URL noted in step 2.
100101
101102 For more details about using Cloud Run see http://cloud.run .
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ public class ConnectionPoolContextListener implements ServletContextListener {
4747 justification = "Necessary for sample region tag." )
4848 private DataSource createConnectionPool () {
4949 // [START cloud_sql_mysql_servlet_create]
50+ // Note: For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections
51+ // which is preferred to using the Cloud SQL Proxy with Unix sockets.
52+ // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details.
53+
5054 // The configuration object specifies behaviors for the connection pool.
5155 HikariConfig config = new HikariConfig ();
5256
@@ -61,8 +65,6 @@ private DataSource createConnectionPool() {
6165 config .setUsername (DB_USER ); // e.g. "root", "mysql"
6266 config .setPassword (DB_PASS ); // e.g. "my-password"
6367
64- // For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections.
65- // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details.
6668 config .addDataSourceProperty ("socketFactory" , "com.google.cloud.sql.mysql.SocketFactory" );
6769 config .addDataSourceProperty ("cloudSqlInstance" , CLOUD_SQL_CONNECTION_NAME );
6870
Original file line number Diff line number Diff line change @@ -47,6 +47,10 @@ public class ConnectionPoolContextListener implements ServletContextListener {
4747 justification = "Necessary for sample region tag." )
4848 private DataSource createConnectionPool () {
4949 // [START cloud_sql_postgres_servlet_create]
50+ // Note: For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections
51+ // which is preferred to using the Cloud SQL Proxy with Unix sockets.
52+ // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details.
53+
5054 // The configuration object specifies behaviors for the connection pool.
5155 HikariConfig config = new HikariConfig ();
5256
@@ -61,8 +65,6 @@ private DataSource createConnectionPool() {
6165 config .setUsername (DB_USER ); // e.g. "root", "postgres"
6266 config .setPassword (DB_PASS ); // e.g. "my-password"
6367
64- // For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections.
65- // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details.
6668 config .addDataSourceProperty ("socketFactory" , "com.google.cloud.sql.postgres.SocketFactory" );
6769 config .addDataSourceProperty ("cloudSqlInstance" , CLOUD_SQL_CONNECTION_NAME );
6870
Original file line number Diff line number Diff line change @@ -42,6 +42,10 @@ public class ConnectionPoolContextListener implements ServletContextListener {
4242
4343 private DataSource createConnectionPool () {
4444 // [START cloud_sql_sqlserver_servlet_create]
45+ // Note: For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections
46+ // which is preferred to using the Cloud SQL Proxy with Unix sockets.
47+ // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details.
48+
4549 // The configuration object specifies behaviors for the connection pool.
4650 HikariConfig config = new HikariConfig ();
4751
@@ -60,8 +64,6 @@ private DataSource createConnectionPool() {
6064 config .setPassword (DB_PASS ); // e.g. "my-password"
6165 config .addDataSourceProperty ("databaseName" , DB_NAME );
6266
63- // For Java users, the Cloud SQL JDBC Socket Factory can provide authenticated connections.
64- // See https://github.com/GoogleCloudPlatform/cloud-sql-jdbc-socket-factory for details.
6567 config .addDataSourceProperty ("socketFactoryClass" ,
6668 "com.google.cloud.sql.sqlserver.SocketFactory" );
6769 config .addDataSourceProperty ("socketFactoryConstructorArg" , CLOUD_SQL_CONNECTION_NAME );
You can’t perform that action at this time.
0 commit comments