I need to connect to database which is located in another server (phpmyadmin domain: nazwa.pl). By phpmyadmin website I can connect to database, so there is no problem with database. Open port is 3307 for db. I have login password host port database name so everything to connect. I tried to connect by tcp/ip then by ssh but I can't connect. And I tried it by java code, by mysql workbench, by mysql terminal, by simply as an ip address but still nothing. And in the java code error was:
SEVERE: null
com.mysql.jdbc.exceptions.jdbc4.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.
And my java code is:
public static int connect() {
try {
DriverManager.registerDriver(new Driver());
conn = DriverManager.getConnection("jdbc:mysql://sql.******.nazwa.pl:3307/******?user=******&password=******&useUnicode=true&characterEncoding=UTF-8");
return 1;
} catch (SQLException ex) {
Logger.getLogger(****.class.getName()).log(Level.SEVERE, null, ex);
return 0;
}
}
public static void main(String[] args) throws JSchException {
if (connect() == 1) {
System.out.println("success");
} else {
System.out.println("error");
}
}
Could someone say at least where should I check my mistake?