PCoder123
PCoder123

Reputation: 364

Connection Timeout EC2 Java Web App to RDS mySQL Database

I am a beginner at AWS. So far I managed to set up a mySQL database in RDS and a EC2 Java Web Application. I am using the eclipse plugin to deploy the web application. I can connect to the Java Web Application through http requests from the browser. Additionally, I can connect to the mySQL database from the command line terminal.

However, whenever I try to connect to the mySQL database from code in the java web application my request times out. I am confident my URL is correct to make the connection in code. And I am just using these lines for the connection. Something I have done numerous times successfully on localhost.

Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection(url);

I have read a lot of information about security groups, but in my RDS management console it says:

"Your account does not support the EC2-Classic Platform in this region. DB Security Groups are only needed when the EC2-Classic Platform is supported. Instead, use VPC Security Groups to control access to your DB Instances."

Does anyone have any suggestions? Thanks in advance!

Upvotes: 0

Views: 1816

Answers (1)

Ben Whaley
Ben Whaley

Reputation: 34406

You have a newer AWS account that only has VPC enabled, not EC2 classic. Access to all your RDS DB instances as well as your EC2 instances will be through VPC security groups.

First check what security group your EC2 instance running the Java web app is in, and do the same for your RDS instance. Then go to the VPC console and look at those security groups. You need to ensure that the EC2 instance can access the RDS instance on port 3306. The best way is to put the EC2 instance in a group, the RDS in another group, then allow access to RDS from the entire group by group ID.

Upvotes: 2

Related Questions