Can't Connect from GCP AppEngine to GCP Cloud SQL

44 views
Skip to first unread message

Caglar Mehmet Metin

unread,
Jul 29, 2019, 10:57:18 AM7/29/19
to Google App Engine

Hello all,


I have a simple Java servlet app, deployed to the GCP AppEngine. 

Under the same GCP project, I have created a MySQL instance of GCP Cloud SQL.


I would like to save the value on MySQL server when someone makes an HTTP Post request. 

However my Java App cannot connect to GCP Cloud SQL.


On Cloud SQL page, it says "All apps in this project. All authorized." 

However my java app can't connect although they are under the same GCP Project.


When I add all the networks, it works correctly. However I don't want to do this.


What could be the reason that I can't connect to Cloud SQL from the App Engine? Is there some configuration that I need to do?

Thanks and regards.

so.PNG


Julie (cloud platform support)

unread,
Jul 29, 2019, 12:40:59 PM7/29/19
to Google App Engine
This is the recommended method for connecting Cloud SQL with App Engine so if you are not connecting as detailed please specify your connection method. If you use 0.0.0.0/0 IP then the issue is unlikely due to configuration of the network as that IP should allow any application to connect (this includes unauthorized ones, which can cause a security issue). Please note that if you have sensitive or proprietary data in your database, you should not use this method to investigate connectivity issues. Please specify if any error messages result from your attempt to connect, specifically any Stack driver logs. Please remove any sensitive or personal information such as cookies, passwords, email addresses and credit card information before posting any attachments/information. 



Caglar Mehmet Metin

unread,
Aug 5, 2019, 4:22:37 PM8/5/19
to Google App Engine
Hello sorry for late reply.

I tried with the recommended method. It now works (with g).  
However HikariConfig does not work. It continuesly throws exception. It only works when I connect normally (Using JDBC driver)
Do you have any idea why? 

DataSource pool = new HikariDataSource(config); //(Does not work)
conn = DriverManager.getConnection(url); //works

Both have the same configs and urls.


Thanks and regards. 

29 Temmuz 2019 Pazartesi 18:40:59 UTC+2 tarihinde Julie (cloud platform support) yazdı:

Nicolas (Google Cloud Platform Support)

unread,
Aug 5, 2019, 5:25:56 PM8/5/19
to Google App Engine

Hi Caglar,

As GCP Google Groups are more oriented towards general opinions, trends, and issues of general nature touching App Engine and Cloud SQL I would recommend bringing this issue to a website such as Stack Overflow, where experienced programmers are within reach and ready to help.


Reply all
Reply to author
Forward
0 new messages