I have a RDS instance (MySQL) and EC2 instance (Spring boot).
Locally, my Spring Boot app correctly establishes the connection to my database in RDS.
But when I install my Spring Boot app in EC2, the application tries to make the connection to the database in RDS (MySQL). But it throws this error at me:
SQLCODE: 0 SQLSTATE: 08S01 TRACE: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
This sound weird; because if something is working from your local laptop which is on public IP address; it should work from within AWS environment too. Anyway, for connection; you need to not check security group of EC2 only but also of RDS because RDS should allow incoming from EC2 also. Though exception doesn't look like connection/security group problem.
I feel it has something to do with your application.