11 messages in com.mysql.lists.javaRe: How to connect to a MySQL DB whic...| From | Sent On | Attachments |
|---|---|---|
| Shridhar | 18 Feb 2003 02:01 | |
| raf...@dcit.com | 18 Feb 2003 07:36 | |
| Shridhar | 18 Feb 2003 19:55 | |
| raf...@dcit.com | 19 Feb 2003 07:10 | |
| Keith Knaide | 19 Feb 2003 07:12 | |
| G. Wayne Kidd | 19 Feb 2003 07:43 | |
| raf...@dcit.com | 19 Feb 2003 08:03 | |
| George Pitcher | 19 Feb 2003 08:35 | |
| Keith Knaide | 19 Feb 2003 09:13 | |
| bbon...@tampabay.rr.com | 19 Feb 2003 11:28 | |
| Shridhar | 19 Feb 2003 20:44 |
| Subject: | Re: How to connect to a MySQL DB which is on a remote machine..![]() |
|---|---|
| From: | raf...@dcit.com (raf...@dcit.com) |
| Date: | 02/18/2003 07:36:04 AM |
| List: | com.mysql.lists.java |
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. ** ============================================================




