简体   繁体   中英

Authorizing App Engine Java Servlet to use Cloud SQL in eclipse

I have written a java servlet in app engine that i am trying to connect to a cloud sql, i am working in eclipse kepler on windows. in the google cloud console i have authorized by app to access the database, they are both stored in the US.

To enable cloud sql for my app in eclipse i am going to google>app engine settings...

i try to configure the cloud sql instance, i am using the appropriate instance name : and i have specified the correct database name username and password, i have also tried with a blank password, and both a blank password and user niether have worked. additionally, i am using the same email account across my database and app engine and eclipse. the error i receive is:

Could not connect to Profile (<project>.GoogleCloudSQL.AppEngineInstance).
Error creating SQL Model Connection connection to 
Profile(<project>.GoogleCloudSQL.AppEngineInstance). (Error: Not authorized to access
instance: <instance:database>)
Not authorized to access instance: <instance:database>
Error creating Google Cloud SQL Connection factory connection to Profile  
(<project>.GoogleCloudSQL.AppEngineInstance). (Error: Not authorized to access 
instance: <instance:database>)
Not authorized to access instance: <instance:database>

i then tried to test the database using the google_sql.sh script provided in the bin folder of the appengine sdk. i sent me to a url to get an authorization code, after entering the authorization code i was just given the script fails stating "the provided authorization grant is invalid, expired, revoked etc.".

i just want my app engine java servlet to be able to access my cloud sql database...does anyone have any advice? a solution? a similar problem?

Please take a look at the following link for the recommended way to connect to your CloudSQL instance from dev purposes. https://developers.google.com/appengine/docs/java/cloud-sql/#connect_and_post

In short, just get an IP address for the CloudSQL instance using admin API or cloud console, authorize your network to access the CloudSQL instance through Cloud console, and point your application to it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM