Issues connecting to remote AWS Database through intellij.
I am having issues connecting to a remote MySQL DB that I set up through AWS. When creating the DB, I ensured that it is publicly accessible, and that I have the Username, Password, Database name, and Database instance typed out correctly. In my code on intellij, I connect with the following:
public String host = "jdbc:mysql://database-instance-name.12-random-chars.us-east 2.rds.amazonaws.com:3306/database-name";
public String userName = "-----DB";
public String passWord = "--------------";
public Connection con;
public Statement statement;
public void connect() {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
con = DriverManager.getConnection(host, userName, passWord);
statement = con.createStatement();
JOptionPane.showMessageDialog(null, "Successfully connected to the database!",
"Success",
JOptionPane.ERROR_MESSAGE);
} catch (SQLException | ClassNotFoundException e) {
JOptionPane.showMessageDialog(null, e.toString(), "Error",
JOptionPane.ERROR_MESSAGE);
}
}
but I am not able to connect to my remote MySQL DB. Instead, I receive the following error:
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.
So it sounds like I am connecting, and sending successfully, but not receiving any data. So I use telnet, and try to connect on the port 3306 (which is what my AWS panel specified) and I receive this following error:
"C:\-----\----->telnet database-instance-name.12-random-chars.us-east-2.rds.amazonaws.com 3306
Connecting To database-instance-name.12-random-chars.us-east-2.rds.amazonaws.com...Could not open connection to the host, on port 3306: Connect failed"
I am confused as I believe the inbound and outbound rules are set properly, and that I it is publicly accessible. 
And the rules for the security group is set to accept all.
This is the error that I receive when I try to connect to it:

The reason why I am looking to the intellij support forums is because I have already posted on the AWS forums on Amazon's website, but have yet to receive a response, so I am helping that someone has worked with Amazon's MySQL DB's and can help me here, thank you in advance!
Please sign in to leave a comment.
Double check the remote database configuration: make sure the instance is up and running and is configured for TCP incoming connection on the specified port. Double check bind-address & port in my.cnf config.
Check also https://stackoverflow.com/a/10772407/2000323.
Hi!!
I am facing the same issue while making the connection between AWS Aurora and JAVA as above.
Did you find a solution to it?
If yes, can you please reply back at email : manpreetkaurassi@gmail.com
It will be very helpful.
Thanx!
Hello,
Have you tried solutions from stackoverflow thread: https://stackoverflow.com/questions/6865538/solving-a-communications-link-failure-with-jdbc-and-mysql/10772407#10772407 ?