Ciao a tutti....sto provando a fare una semplice applicazione che si collega ad un Database MySQL...ho scaricato il Driver e l'ho linkato tra le librerie dell'app...eseguo questo codice x la connessione al DB:
<CODE>
try {
// Load the MySQL JDBC driver
try {
Class.forName("org.gjt.mm.mysql.Driver");
} catch (ClassNotFoundException e) {
System.out.println ("MySQL device driver does not exist");
System.exit(1);
}
}catch (Exception e) {}
System.out.println("Driver ok");
}
try{
// Connect to the database
// You can put a database name after the @ sign in the connection URL.
System.out.println("Tento la conn");
conn =
DriverManager.getConnection ("jdbc:mysql://ip-remoto-DB:3306/DATABASE","user","pass");
System.out.println("Connessione ok");
// Create a Statement
stmt = conn.createStatement ();
}catch(SQLException e){
System.out.println("Error accessing DB ");
System.out.println(" Error code is : "+e.getErrorCode());
System.out.println(" Error message is :"+e.getMessage());
</CODE>
e dopo un po' di attesa invece di darmi "Connessione ok" mi da il seguente errore:
Error accessing DB
Error code is : 0
Error message is :Unable to connect to any hosts due to exception: java.net.ConnectException: Connection timed out: connect
come mai????
Ho cercato sul forum ma nn ho trovato nessuno che ha avuto un prob simile.....a tutti funziona il codice simile a quello che ho usato io....bho....HELP PLZ