Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect GAE to Amazon RDS?

I have a database instance on Amazon RDS which is configured:

Amazon RDS Instance

My VPC Security group, both Inbound and Outbound are configured like below:

VPC Security Group

My VPC DNS Resolution and DNS Hostnames are activated. I can connect to this instance and execute queries without problems from MySQLWorkbench. I'm configuring it in my GAE Eclipse using persistence.xml:

 <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:

<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:

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.

Please, any suggestion, clue, tip will be very appreciate once I'm trying to fix it for the last whole week.

Thanks you guys!

like image 910
John Santos Avatar asked Nov 08 '22 07:11

John Santos


1 Answers

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.

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.

That's it. I hope it helps someone else.

like image 68
John Santos Avatar answered Nov 14 '22 22:11

John Santos