wood burning stoves 2.0*
The moose likes JDBC and the fly likes connection to remote mysql db Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "connection to remote mysql db" Watch "connection to remote mysql db" New topic
Author

connection to remote mysql db

Nouf Nassri
Ranch Hand

Joined: Apr 22, 2010
Posts: 40
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

Joined: Feb 23, 2007
Posts: 1561
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
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Feb 05, 2010
Posts: 56
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.


--Himanshu Jain
http://jainhim.blogspot.com/
Nouf Nassri
Ranch Hand

Joined: Apr 22, 2010
Posts: 40
thanks ,

Code:
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Hi Nouf,

Please also post the error messages you get.

Regards, Jan


OCUP UML fundamental and ITIL foundation
youtube channel
Nouf Nassri
Ranch Hand

Joined: Apr 22, 2010
Posts: 40
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

Joined: Dec 20, 2006
Posts: 2491
    
    8

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

Joined: May 07, 2010
Posts: 15
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.


Why most of the people are so cruel? Most of the time, I have to be the same.
 
Consider Paul's rocket mass heater.
 
subject: connection to remote mysql db
 
Similar Threads
db connection problem
problems connecting to remote db thru jdbc app
execution arguments
Remote JDBC connection performance question
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection