On Wednesday, March 4, 2020 at 1:41:52 PM UTC-8, Kurtis Van Gent wrote:
To add additional context, the library you are using (`com.google.cloud.sql.mysql.SocketFactory`) uses an in-process "Cloud SQL proxy", which means it connects through the same server side proxy that the binary Cloud SQL proxy connects through.
TL:DR; Using the Cloud SQL JDBC socket factory counts as using the Cloud SQL proxy.On Wednesday, March 4, 2020 at 9:03:46 AM UTC-8 noverlyjoseph wrote:If you're running this locally, Cloud SQL proxy will be used then.
https://cloud.google.com/sql/docs/mysql/connect-app-engine# best_practices_other_ information https://cloud.google.com/sql/docs/mysql/connect-app-engine# connecting_to
On Wednesday, March 4, 2020 at 9:30:55 AM UTC-5, Khanh Phan wrote:My Google Cloud mySQL is setup and running. In the user table, I have created id=test and allowed it to connect from % (any host)
I have a small Java program
Properties dbcpProperties = new Properties(); String CLOUD_SQL_CONNECTION_NAME = "google_project:us-central1:
instance"; dbcpProperties.put(" driverClassName","com.mysql. jdbc.Driver"); dbcpProperties.put("url", String.format( "jdbc:mysql://google/%s? socketFactory=com.google. cloud.sql.mysql.SocketFactory" + "&cloudSqlInstance=%s", DB_NAME, CLOUD_SQL_CONNECTION_NAME)); dbcpProperties.put("username", DB_USER); dbcpProperties.put("password", DB_PASS); try { BasicDataSource dataSource = (BasicDataSource) BasicDataSourceFactory. createDataSource( dbcpProperties); System.out.println("UPN Data source succesfully created."); } catch (Exception e) { System.out.println("FATAL ERROR: Couldn't create new Data source."); throw new RuntimeException(e); } Everytime I run it, it complains Caused by: org.apache.commons.dbcp.
SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'test'@'cloudsqlproxy~ myipaddress' (using password: YES)) at org.apache.commons.dbcp. BasicDataSource. createPoolableConnectionFactor y(BasicDataSource.java:1549) at org.apache.commons.dbcp. BasicDataSource. createDataSource( BasicDataSource.java:1388) at org.apache.commons.dbcp. BasicDataSource.getLogWriter( BasicDataSource.java:1098) at org.apache.commons.dbcp. BasicDataSourceFactory. createDataSource( BasicDataSourceFactory.java: 350) at test.Test.connect2CloudMySQL2( Test.java:1345) ... 6 more But if I allowed user test to connect from any cloudsqlproxy~%, then it works
Why does it insists on using cloudsqlproxy ? How can I disable that?
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/0aff8293-d9d9-49f9-9cd7-727d84025dda%40googlegroups.com.
No comments:
Post a Comment