Hi, all.

First, I should give some information on the setting:

I have mysql database, say, mydatabase, existing in one machine A which is
Solaris; I am trying to connect this database from another XP machine.

The code snippet  in the XP machine looks like this:

String driver = "com.mysql.jdbc.Driver";
String URL = "jdbc:mysql://url:3306/mydatabase";
String username = "abc";
String password = "abc";
Connection con;

Class.forName(driver).newInstance();
con = DriverManager.getConnection(URL, username, password);

I got error like this:

root cause

java.sql.SQLException: Unable to connect to any hosts due to exception:
java.net.ConnectException: Connection timed out: connect

I did some search before I come to ask it. There's a very similar question
in this internet:

http://forum.java.sun.com/thread.jspa?threadID=564265&messageID=2780194

>From there I got the test code to test if the 3306 port is accessible:

import java.net.*;

public class MySQLConnectTest{

  public static void main(String args[])throws Exception{
    String hostname = "129.173.23.53"; // replace with IP of your router
    Socket s = new Socket(hostname,3306);
    System.out.println("Got connection!");
    s.close();
  }
}

If I run this code in other few Solaris machines, I got connection. But if
I run this code on the XP machine, I got time out.

I also tried on the XP machine this:

ping the machine with mysql database: ping aaa.bbb.ca, this works

then I tried 'telnet':

telnet aaa.bbb.ca or telnet aaa.bbb.ca:3306

both case, it said:  Could not connected to the host , on port 23: connect
failed.

>From those tests, I am thinking there are some issues about letting the XP
machine to connect the database. Is there some setting I need to do on the
database so that it will allow certain machine to access the database

Any one can give a hand?

Thanks in advance.

X.Chen


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to