Communications link failure connecting spring boot app to aws aurora

Tags: , , ,



I am trying to connect the spring boot application I have created locally to an aws serverless aurora database.

I have added the maven dependency:

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>8.0.18</version>
    </dependency>

As well as created an application.properties file:

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.show-sql=true
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://myawsclusterlink:3306/mycluster
spring.datasource.username=myusername
spring.datasource.password=mypassword
spring.datasource.hikari.minimum-idle=0
spring.datasource.hikari.maximum-pool-size=10
spring.datasource.hikari.connection-timeout=60000
spring.datasource.hikari.max-lifetime=90000
spring.datasource.hikari.idle-timeout=90000

I have also created a VPC inbounds group for the db to allow incoming traffic from my IP address.

My Issue is that that when I run the app, my connection keeps failing with an error message:

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.

I would like to know where is the problem. Is my url wrong? Have I not enabled something on aws? Is there something missing in my code?

Also, I don’t really know how to test and see where the problem is coming from in this case.

Answer

Changing from serverless to provisioned aurora and enabling public access solved the issue



Source: stackoverflow