11 messages in com.mysql.lists.javaRe: How to connect to a MySQL DB whic...
FromSent OnAttachments
Shridhar18 Feb 2003 02:01 
raf...@dcit.com18 Feb 2003 07:36 
Shridhar18 Feb 2003 19:55 
raf...@dcit.com19 Feb 2003 07:10 
Keith Knaide19 Feb 2003 07:12 
G. Wayne Kidd19 Feb 2003 07:43 
raf...@dcit.com19 Feb 2003 08:03 
George Pitcher19 Feb 2003 08:35 
Keith Knaide19 Feb 2003 09:13 
bbon...@tampabay.rr.com19 Feb 2003 11:28 
Shridhar19 Feb 2003 20:44 
Subject:Re: How to connect to a MySQL DB which is on a remote machine..
From:Keith Knaide (kna@yahoo.com)
Date:02/19/2003 07:12:31 AM
List:com.mysql.lists.java

Shridhar,

Try adding the default port (3306) to the url so that it looks like this...

203.197.167.163:3306

Hope that works! Keith

--- Shridhar <Shri@hotmail.com> wrote:

Hello,

No, i am not able to connect to the remote machine with myqsl client .. i tried these commands , it is throwing the following Error..

C:\>mysql -h 203.197.167.163 -u root ERROR 2003: Can't connect to MySQL server on '203.197.167.163' (10060)

C:\>mysql -h 203.197.167.163 -u root -p Enter password: root ERROR 2003: Can't connect to MySQL server on '203.197.167.163' (10060)

what might be the problem????

----- Original Message ----- From: <raf@dcit.com> To: <ja@lists.mysql.com> Sent: Tuesday, February 18, 2003 21:06 Subject: Re: How to connect to a MySQL DB which is on a remote machine..

Can you ping the other box? Can you connect to the mysql server running on the other machine from a mysql client on your "coding" machine?

Shridhar wrote:

Hi All,

How to connect to a MySQL db which is on a remote machine I tried the , but i'm getting SQLException.. Please tell me where am i going wrong..

Thanks, Shridhar..

The Code: =======

try { System.out.println("Hello ");

Class.forName("org.gjt.mm.mysql.Driver");

System.out.println("Class Loaded : "); String url = "jdbc:mysql://IPAddr_of_remote_machine/dbName"; Connection dbCon = DriverManager.getConnection(url, "root", ""); System.out.println("conn : "); Statement vSt = dbCon.createStatement(); System.out.println("stmt : "); String ReqStr = "select * from test_table"; ResultSet vRs = vSt.executeQuery(ReqStr); while(vRs.next()) { System.out.println(vRs.getString(1)); } } catch(Exception e) { e.printStackTrace() ; }

Output : ======

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

com.mysql.jdbc.Connection.createNewIO(Connection.java:1670)

at

com.mysql.jdbc.Connection.connectionInit(Connection.java:901)

at com.mysql.jdbc.Driver.connect(Driver.java:311) at

java.sql.DriverManager.getConnection(DriverManager.java:512)

at

java.sql.DriverManager.getConnection(DriverManager.java:171)

at aa.main(aa.java:19) Interactive Session Ended

---------------------------------------------------------------------

Before posting, please check: http://www.mysql.com/doc/ (the manual) http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <java@lists.mysql.com> To unsubscribe, e-mail

<java-unsubscribe-raffi=dcit@lists.mysql.com>

-- Raffi Minassian DCIT Corporation http://www.dcit.com

============================================================

** Nothing is so embarrassing as watching someone do something that you said couldn't be done. **

============================================================

---------------------------------------------------------------------

Before posting, please check: http://www.mysql.com/doc/ (the manual) http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <java@lists.mysql.com> To unsubscribe, e-mail

<java-unsubscribe-shri1976=hotm@lists.mysql.com>

---------------------------------------------------------------------

Before posting, please check: http://www.mysql.com/doc/ (the manual) http://lists.mysql.com/ (the list archive)

To request this thread, e-mail <java@lists.mysql.com> To unsubscribe, e-mail

<java-unsubscribe-knaide=yaho@lists.mysql.com>