I am trying to connect to MariaDB installed in AWS machine from my local machine. 3306 port is opened for that machine from local machine.
I have set bind-address=0.0.0.0
in /etc/my.cnf.d/server.cnf file in aws machine and also has set security group for 3306
From my local machine, when I execute the following java code,
`
Connection conn = null;
Class.forName("org.mariadb.jdbc.Driver");
//STEP 3: Open a connection
System.out.println("Connecting to a selected database...");
conn = DriverManager.getConnection(
"jdbc:mariadb://ip:3306/DB", "username", "password");
System.out.println("Connected database successfully...");
Gives the following error:
java.sql.SQLNonTransientConnectionException: Could not connect to ip:3306 : Connection reset
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.get(ExceptionMapper.java:175)
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getException(ExceptionMapper.java:110)
at org.mariadb.jdbc.internal.protocol.AbstractConnectProtocol.connectWithoutProxy(AbstractConnectProtocol.java:1113)
at org.mariadb.jdbc.internal.util.Utils.retrieveProxy(Utils.java:503)
at org.mariadb.jdbc.MariaDbConnection.newConnection(MariaDbConnection.java:155)
at org.mariadb.jdbc.Driver.connect(Driver.java:86)