I am having a hard time understanding what I'm doing wrong while trying to connect to a database that is hosted on a domain from https://www.biz.nf/. My java web app using tomcat server runs on localhost:8080 while the database is served at fdb27.biz.nf on port 3306. Does the database and server have to be running on the same port? I tried changing the bind address in program data /MySQL/ my.cnf to the ip address of my network and it didn't change anything. Also tried changing the bind-address to 0.0.0.0 and even commenting it out.
I am connecting to the mysql database like this(DBNAME is just a replacement of my actual database name):
Class.forName("com.mysql.cj.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:mysql://fdb27.biz.nf:3306/DBNAME", DBNAME, password);
My error log:
Caused by: com.mysql.cj.exceptions.CJCommunicationsException: 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.
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151)
at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167)
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:89)
at com.mysql.cj.NativeSession.connect(NativeSession.java:144)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:953)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:823)
... 32 more
Caused by: java.net.ConnectException: Connection refused: connect
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:574)
at java.base/sun.nio.ch.Net.connect(Net.java:563)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:588)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:333)
at java.base/java.net.Socket.connect(Socket.java:648)
at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155)
at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:63)
... 35 more
EDIT:
Verified IP / URL is correct
JDBC is recognized
DB server is up and running
Ports open for all network interfaces: 3306, 5900, 33060
Z:\>netstat -ano | find "3306"
TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING 30152
TCP 0.0.0.0:33060 0.0.0.0:0 LISTENING 30152
TCP 127.0.0.1:3306 127.0.0.1:53033 ESTABLISHED 30152
TCP 127.0.0.1:3306 127.0.0.1:53034 ESTABLISHED 30152
TCP 127.0.0.1:53033 127.0.0.1:3306 ESTABLISHED 30376
TCP 127.0.0.1:53034 127.0.0.1:3306 ESTABLISHED 30376
TCP [::]:3306 [::]:0 LISTENING 30152
TCP [::]:33060 [::]:0 LISTENING 30152