3

I've tried to install an instance on AWS using aws RDS as my datasource through the mysql-connector-java-5.1.45-bin.jar with jdbc url

jdbc:mysql://< instance>.< zone>.rds.amazonaws.com:3306/carbon_db

I've got an exception

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failurecom.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

    The last packet successfully received from the server was 7 milliseconds ago.  The last packet sent successfully to the server was 7 milliseconds ago.
            at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
            at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
            at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
            at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
    .
    .
    .
    Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: unknown_ca

I've tried to run

keytool -importcert -keystore <keystore> -storepass <pass> -noprompt -file rds-combined-ca-bundle.pem

on cacerts.jks in JVM and client-trustore.jks inside WSO2 repository with no change

1 Answer 1

0

If you get a SQLException: Connection refused or Connection timed out or a MySQL specific CommunicationsException: Communications link failure, then it means that the DB isn't reachable at all. This can have one or more of the following causes:

IP address or hostname in JDBC URL is wrong.
Hostname in JDBC URL is not recognized by local DNS server.
Port number is missing or wrong in JDBC URL.
DB server is down.
DB server doesn't accept TCP/IP connections.
DB server has run out of connections.
Something in between Java and DB is blocking connections, e.g. a firewall or proxy. 

To solve the one or the other, follow the following advices:

Verify and test them with ping.
Refresh DNS or use IP address in JDBC URL instead.
Verify it based on my.cnf of MySQL DB.
Start the DB.
Verify if mysqld is started without the --skip-networking option.
Restart the DB and fix your code accordingly that it closes connections in finally.
Disable firewall and/or configure firewall/proxy to allow/forward the port. 
1
  • I too encountered this issue and your answer seems not be addressing it. The cause for this issue is, RDS tries to verify the client certificate (which is optional) if available. I still couldn't find a solution for that. Dec 26, 2019 at 14:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .