TL:DR; Using the Cloud SQL JDBC socket factory counts as using the Cloud SQL proxy.
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:in
stance"; dbcpProperties.put("driverClas sName","com.mysql.jdbc.Driver" ); dbcpProperties.put("url", String.format( "jdbc:mysql://google/%s?socket Factory=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.createD ataSource( 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.SQLNes
tedException: Cannot create PoolableConnectionFactory (Access denied for user 'test'@'cloudsqlproxy~myipaddr ess' (using password: YES)) at org.apache.commons.dbcp.BasicD ataSource.createPoolableConnec tionFactory(BasicDataSource. java:1549) at org.apache.commons.dbcp.BasicD ataSource.createDataSource(Bas icDataSource.java:1388) at org.apache.commons.dbcp.BasicD ataSource.getLogWriter(BasicDa taSource.java:1098) at org.apache.commons.dbcp.BasicD ataSourceFactory.createDataSou rce(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/9e688248-48c3-428a-87c7-badb688f383e%40googlegroups.com.
No comments:
Post a Comment