简体   繁体   English

如何将GAE连接到Amazon RDS?

[英]How to connect GAE to Amazon RDS?

I have a database instance on Amazon RDS which is configured: 我在Amazon RDS上有一个配置的数据库实例:

Amazon RDS Instance 亚马逊RDS实例

My VPC Security group, both Inbound and Outbound are configured like below: 我的VPC安全组(入站和出站)配置如下:

VPC Security Group VPC安全组

My VPC DNS Resolution and DNS Hostnames are activated. 我的VPC DNS解析和DNS主机名已激活。 I can connect to this instance and execute queries without problems from MySQLWorkbench. 我可以连接到这个实例并执行查询而不会出现MySQLWorkbench的问题。 I'm configuring it in my GAE Eclipse using persistence.xml: 我正在使用persistence.xml在我的GAE Eclipse中配置它:

 <persistence-unit name="myworld">
   <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider > 

   <!--             MODELS            -->
   ...

   <properties>
       <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/>
       <property name="javax.persistence.jdbc.url" value="jdbc:mysql://myworld.cy3caqn3kkz0.eu-west-1.rds.amazonaws.com:3306/myworld"/>
       <property name="javax.persistence.jdbc.user" value="myworld"/>
       <property name="javax.persistence.jdbc.password" value="******"/>
       <property name="eclipselink.target-database" value="org.eclipse.persistence.platform.database.MySQLPlatform" />
   </properties>  

And my appengine_web.xml: 还有我的appengine_web.xml:

<threadsafe>true</threadsafe>

 <system-properties>
    <property name="java.util.logging.config.file" value="WEB-INF/logging.properties"/>
    <property name="ae-cloudsql.cloudsql-database-url" value="jdbc:mysql://myworld.cy3caqn3kkz0.eu-west-1.rds.amazonaws.com:3306/myworld?user=myworld&amp;password=******" />
    <property name="cloudsql.url" value="jdbc:mysql://myworld.cy3caqn3kkz0.eu-west-1.rds.amazonaws.com:3306/myworld?user=myworld&amp;password=******"/>
 </system-properties>

I'm able to connect and execute queries when I start my GAE project locally and everything works fine but when I deploy it online I receive the following exception: 当我在本地启动GAE项目时,我能够连接并执行查询,一切正常,但是当我在线部署它时,我收到以下异常:

Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.5.1.v20130918-f2b9fc5): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
Error Code: 0

I have read lots of posts, blogs, questions and answers on stackoverflow but I didn't figured out what I'm doing wrong. 我已经在stackoverflow上阅读了很多帖子,博客,问题和答案,但我没弄明白我做错了什么。

Please, any suggestion, clue, tip will be very appreciate once I'm trying to fix it for the last whole week. 拜托,任何建议,线索,小费都会非常感激,一旦我试图在最后一周修复它。

Thanks you guys! 谢谢你们!

I finally could get it working!! 我终于可以让它运作!! It sounds stupid for me but it can be useful for someone who can be experiencing the same problem. 这对我来说听起来很愚蠢,但对于可能遇到同样问题的人来说,这可能很有用。 Everything was fine with the projects and their configuration, the only thing I didn't do was activate the billing for my PROJECT . 项目及其配置一切都很好,我唯一没做的就是激活我的PROJECT的计费

Yes, you activate you billing account as soon as you create an account on GAE BUT when you create a project you need to LINK YOUR PROJECT BILLING TO THE BILLING ACCOUNT YOU HAVE CREATED. 是的,在创建项目时,只要您在GAE BUT上创建帐户,就会激活您的结算帐户,您需要将项目结算链接到您创建的结算帐户

That's it. 而已。 I hope it helps someone else. 我希望它可以帮助别人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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