• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connection to remote mysql db

 
Nouf Nassri
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello to all That,

I developed a java application and I use mysql for the db. Everything goes smoothly when I'm working on localhost, but when I test the application server with my windows server 2003 remote every time I get the message telling me that the MySQL seveur was not found.
What should I do to solve this problem??
Thank you in advance.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

This doesn't sound like a Swing problem and I request that the mods move it to the data base forum. That being said, you may wish to post the code you use to try to connect to the remote database.

Much luck!
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all you should write your code so that it looks at the computer where the database is actually located. Be aware that "localhost" means "this computer" no matter what computer your code is running on.

And second you should arrange your network configuration so that your code can actually reach that computer.

Based on what you posted there is no way to tell what your real problem is, so that's just general advice.

And yes, clearly it isn't anything to do with Swing. I expect this question gets asked all the time in the JDBC forum so I will move this post there.
 
him jain
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only problem, as per me, seems to be that your PC is not able to locate Mysql.
So, while doing connectivity means JDBC, you need to specify the IP of the computer where your mysql is located.
If that's fine, then there is problem in configuration and settings that you need to do in windows, like setting up System DSN and username and password of mysql at that particular PC.
These are the general mistakes.
If still there's any problem, better post your code.
 
Nouf Nassri
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks ,

Code:
 
Jan Cumps
Bartender
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Nouf,

Please also post the error messages you get.

Regards, Jan
 
Nouf Nassri
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
run:
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

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

STACKTRACE:

java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:525)
at java.net.Socket.connect(Socket.java:475)
at java.net.Socket.<init>(Socket.java:372)
at java.net.Socket.<init>(Socket.java:215)
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:173)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:267)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2739)
at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.ntic.acces_donnees.Connexion.Getconnection(Connexion.java:22)
at com.ntic.acces_donnees.ExecuteQuery.selection(ExecuteQuery.java:17)
at com.ntic.frame.Employe.ChargerMatrSpinner(Employe.java:123)
at com.ntic.frame.Employe.<init>(Employe.java:110)
at com.ntic.frame.Employe$22.run(Employe.java:1303)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)


** END NESTED EXCEPTION **



Last packet sent to the server was 0 ms ago.
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2814)
at com.mysql.jdbc.Connection.<init>(Connection.java:1553)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at com.ntic.acces_donnees.Connexion.Getconnection(Connexion.java:22)
at com.ntic.acces_donnees.ExecuteQuery.selection(ExecuteQuery.java:17)
at com.ntic.frame.Employe.ChargerMatrSpinner(Employe.java:123)
at com.ntic.frame.Employe.<init>(Employe.java:110)
at com.ntic.frame.Employe$22.run(Employe.java:1303)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
 
Jan Cumps
Bartender
Posts: 2602
13
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A few things you can check:

- Is that remote database up and running?
- Does it run on the default MySQL port.
- Can you ping 192.128.2.100 from the computer that runs your Java code?
- Can you connect to that database with the MySQL GUI Tools?
- Is the database running at some hosting provider (check if the provider allows you to connect to the database via internet)?
 
Ochi Elty
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you allow the user 'root' to access mysql server on 192.128.2.100 from you machine. I remember, mysql server on 192.128.2.100 must be configured to allow connection from your IP address.

You can check if this is set up by executing this query on your mysql server:

select user, host from mysql.user where user='root';

Hope this helps.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic