badperson
July 4th, 2008, 10:19 PM
Hi,
posted this on another forum, but thought I'd put it here, too.
I wrote some simple jdbc code, which I'm pretty sure is right, because it attemps to make the connection, but times out.
I think it has something to do with which port is listening on the server
I'm trying to connect a java application to a mysql database on a machine running ubuntu server. The machine the java app is written and run on is ubuntu desktop.
Here is the relevant java code:
String url="jdbc:mysql://jasonServer/phototestdb";
Connection con = DriverManager.getConnection(url, p);
('p' is a Properties object containing user and pw).
I get this error:
**** NOTE this is the wrong error, it should be a connection timed out error, but it looks the same
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection refused
// bunch of stack trace stuff...
I've tried a couple ways of connecting in the url,
String url="jdbc:mysql://jasonServer/phototestdb";
String url="jdbc:mysql://jasonServer:3306/phototestdb";
String url="jdbc:mysql://99.999.9.99/phototestdb"; (9's are my ip address, I have static ip's on wireless network)
String url="jdbc:mysql://99.999.9.99:3306/phototestdb";
when I have the ip in the url, it fails immediately and gives me a connection refused error:
establishing connection
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection refuse
But when I have the server name in the url, it hangs for a long time and then gives me the timeout error.
Couple other relevant notes;
I am able to ping the server from the desktop using the server name, i.e,
ping jasonServer
but not using the ip addres
I am not able to telnet in the terminal window, I type
telnet jasonServer 3306,
it says "Trying (ip address)
and it just hangs there.
This leads me to believe this isn't really a java issue
but something to do with my network.
One more thing, I think the mysql config file on the server has it set to only listen to the local host...(I don't have the file in front of me, or I'd paste the line of code)
I tried changing that but no luck.
Any ideas?
bp
posted this on another forum, but thought I'd put it here, too.
I wrote some simple jdbc code, which I'm pretty sure is right, because it attemps to make the connection, but times out.
I think it has something to do with which port is listening on the server
I'm trying to connect a java application to a mysql database on a machine running ubuntu server. The machine the java app is written and run on is ubuntu desktop.
Here is the relevant java code:
String url="jdbc:mysql://jasonServer/phototestdb";
Connection con = DriverManager.getConnection(url, p);
('p' is a Properties object containing user and pw).
I get this error:
**** NOTE this is the wrong error, it should be a connection timed out error, but it looks the same
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection refused
// bunch of stack trace stuff...
I've tried a couple ways of connecting in the url,
String url="jdbc:mysql://jasonServer/phototestdb";
String url="jdbc:mysql://jasonServer:3306/phototestdb";
String url="jdbc:mysql://99.999.9.99/phototestdb"; (9's are my ip address, I have static ip's on wireless network)
String url="jdbc:mysql://99.999.9.99:3306/phototestdb";
when I have the ip in the url, it fails immediately and gives me a connection refused error:
establishing connection
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection refuse
But when I have the server name in the url, it hangs for a long time and then gives me the timeout error.
Couple other relevant notes;
I am able to ping the server from the desktop using the server name, i.e,
ping jasonServer
but not using the ip addres
I am not able to telnet in the terminal window, I type
telnet jasonServer 3306,
it says "Trying (ip address)
and it just hangs there.
This leads me to believe this isn't really a java issue
but something to do with my network.
One more thing, I think the mysql config file on the server has it set to only listen to the local host...(I don't have the file in front of me, or I'd paste the line of code)
I tried changing that but no luck.
Any ideas?
bp