簡體   English   中英

授權App Engine Java Servlet在Eclipse中使用Cloud SQL

[英]Authorizing App Engine Java Servlet to use Cloud SQL in eclipse

我在應用引擎中編寫了一個Java Servlet,試圖連接到雲sql,我在Windows上的eclipse kepler中工作。 在Google Cloud Console中,我已獲得應用程序的授權訪問數據庫,它們都存儲在美國。

要在eclipse中為我的應用啟用cloud sql,我要轉到google>應用引擎設置...

我嘗試配置雲sql實例,我使用適當的實例名稱:並且我指定了正確的數據庫名稱用戶名和密碼,我還嘗試使用空密碼,並且空密碼和用戶都可以使用。 此外,我在數據庫,應用程序引擎和Eclipse中使用相同的電子郵件帳戶。 我收到的錯誤是:

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>

然后,我嘗試使用appengine sdk的bin文件夾中提供的google_sql.sh腳本測試數據庫。 我將我發送到url以獲取授權碼,輸入授權碼后,我只是被告知腳本失敗,指出“所提供的授權授予無效,已過期,已撤銷等。”。

我只希望我的應用程序引擎Java Servlet能夠訪問我的雲SQL數據庫...有人有什么建議嗎? 一個解法? 類似的問題?

請查看以下鏈接,了解從開發目的連接到CloudSQL實例的推薦方法。 https://developers.google.com/appengine/docs/java/cloud-sql/#connect_and_post

簡而言之,只需使用管理API或雲控制台獲取CloudSQL實例的IP地址,授權您的網絡通過Cloud控制台訪問CloudSQL實例,然后將您的應用程序指向該實例即可。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM