I have create a simple Java desktop app in Eclipse. I use jdbc mysql plugin to connect to my database. The program runs fine when the database is local i.e on WAMP but when I add an online database. It gives me a Communication links failiure, The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
.
I tried to check if my firewall is blocking it or not using telnet
but when I run telnet subinfo.xyz 2082
, it just goes blank.
I think the jdbc:mysql://subinfo.xyz:2082/subinfo_hsy123
is not right. Is there any other way to connect to an online database?
package application;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
public class DbConn {
// is this the right way to to do?
String url = "jdbc:mysql://subinfo.xyz:2082/db1";
String user = "username";
String password = "password";
public Connection conn;
public Connection connect(){
// Load the Connector/J driver
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (InstantiationException e) {
Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Error Dialog");
alert.setHeaderText("Error Occured!");
alert.setContentText("Ooops, Please check internet or make sure you have working hosting plan!");
alert.showAndWait();
// TODO Auto-generated catch block
e.printStackTrace();
}