1
votes

I created DB Instance (MySQL) with Publicly Accessible option. In DB Security group, I opened MySQL Port for EC2 instance security group(Web server). In EC2 security group it allows ssh, web server ports. I can able to connect DB Instance from EC2 instance. I deployed web app on web server and it can't able to connect with RDS Instance.

I am getting the exception in my local web server:

org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: Server connection failure during transaction. Due to underlying exception: 'java.net.UnknownHostException: "kbawstry2.cdhtaamn5ynq.us-east-1.rds.amazonaws.com"'.

EC2 Security Group EC2 Security Group

DBInstance Security Group DBInstance Security Group

Using MySQL WorkBench, I can connect to RDS DB Instance using TCP/IP SSH Tunnelling option. But in Java Programming How can I connect with database?

Thanks in advance.

1
can you also tell the outbound rule for your ec2 instance security group?user156327
All traffic are opened in outbound both in EC2 Security group and DB Instance Security Group.Kumaresh Babu N S
What DNS server is configured for the EC2 instance?Alexander Yanyshin
Really, I don't know. I installed and configure apache-tomcat 7 for deploying web apps.Kumaresh Babu N S
@KumareshBabu Could you share the code, where DB connection code is written ?user156327

1 Answers

1
votes

Finally I solved the issue. The problem is in application the way I mentioned connection string. I rectified and tested application in localhost then updated to tomcat server in EC2 instance. Another change in DB Security Group. I replaced source ip as EC2 instance's private IP address as both RDS and EC2 Instance are in same VPC.

Now It is working fine.