Hello,

I've made a program that connects to a Mysql database, but when i connect to my local host (a mysql database on a apache server) it works just fine.

I've also got an account at www.downfire.com and there's my online mysql database which I also use for a website.

When i try to connect to this database i get the following error:

Exception in thread "main" com.mysql.jdbc.CommunicationsException: Communication
s link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection timed out: connect

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection timed out: conne
ct
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.ja
va:151)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1765)
at com.mysql.jdbc.Connection.<init>(Connection.java:430)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:268)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestDB.main(TestDB.java:32)


** END NESTED EXCEPTION **


at com.mysql.jdbc.Connection.createNewIO(Connection.java:1830)
at com.mysql.jdbc.Connection.<init>(Connection.java:430)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java
:268)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at TestDB.main(TestDB.java:32)


The code i use is :


import java.sql.*;
import java.awt.*;
import java.awt.event.*;




public class TestDB {


public static void main(String[] args) throws Exception {

System.out.print("Geef FilmNaam in :");
String result = Invoer.leesString();


System.out.println("Registreren Driver....");
Class.forName("com.mysql.jdbc.Driver");
System.out.println("OK");

System.out.println("Maken Connectie....");


//local settings
/*String mysqlUser = "localuser";
String mysqlPass = "";
String mysqlHost = "localhost/dbname";*/


//online settings
String mysqlUser = "user";
String mysqlPass = "password";
String mysqlHost = "192.168.0.11/dbname";


Connection conn = DriverManager.getConnection("jdbc:mysql://"+mysqlHost, mysqlUser, mysqlPass);
System.out.println("OK");

System.out.println("Statement aanmaken.....");
Statement statement=conn.createStatement();

System.out.println("OK");

System.out.println("Uitvoeren Query\n\n\n\n\n");
ResultSet rs = statement.executeQuery("select naam from naam where naam like " +"'%"+result+"%'");
System.out.println("***********************************************************");
while (rs.next()){


System.out.println(rs.getString(1));

}
System.out.println("***********************************************************");



System.out.println("\n\n\n\n\nConnectie afsluiten");
conn.close();
System.out.println("OK.");


}

}