This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes Communications link failure with MySQL 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 "Communications link failure with MySQL" Watch "Communications link failure with MySQL" New topic

Communications link failure with MySQL

Mike Clarkson

Joined: Dec 31, 2009
Posts: 4
i'm trying to create a java application [it's been a while since i have], and i'm trying to connect to mysql with the latest connector/J [5.1.10] and on my windows 7 machine i get the following error. but on my ubuntu laptop, it works just fine

the code i'm running is this:

on my windows machine, the error is as follows:

as i stated before, it works fine on my ubuntu machine, my debian box running mysql accepts remote connections. the only issue is trying to run from my windows 7 machine [uac turned off, eclipse run as administrator]

any help would be greatly appreciated
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3816

If same code runs on another distribution, then there might be something with the Windows 7 (may be it blocks those incoming packets).Have you tried disabling firewall etc..?

[How to ask questions] [Twitter]
Vijitha Kumara

Joined: Mar 24, 2008
Posts: 3816

And Welcome to JavaRanch, Mike

Happy & Prosperous New Year to all the Ranchers
Mike Clarkson

Joined: Dec 31, 2009
Posts: 4
my windows firewall is turned off, and when i tried to telnet to my debian machine [where mysql is] on port 3306, putty just exits with no notice. i'm wondering if it's my router that is blocking traffic, but why blocking on the windows side and not the linux side [as my laptop runs ubuntu and can connect just fine]? if it's not my router, what in windows could be blocking the connection? i have no other software firewall running, and i've even disabled my antivirus just in case. this is really confusing...

and thanks for the welcome and the new years wishes, same to you!
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 9930

Just a guess - Usually, that exception is a result of incorrect JDBC driver jar being used for the version of the MySQL server. Are you sure the MySQL server on your Windows system is the same as the one on Ubuntu and the driver jar you are using on Windows is the right one?

[My Blog] [JavaRanch Journal]
Mike Clarkson

Joined: Dec 31, 2009
Posts: 4
i don't have a mysql server on my windows machine or on my ubuntu machine. it's only installed on my debian machine. ubuntu can connect to mysql just fine, windows can not for some reason.

mysql: 5.0.51a [standard from the debian lenny repos]
connector/j: 5.1.10
java: [on windows] and on my ubuntu machine

i wonder if that minor revision of java is the problem...

thanks for the suggestions!
Peter Johnson

Joined: May 14, 2008
Posts: 5812

From the Windows machine, try running this and see what you get:

telnet 3306

You should get some garbage characters back. (You can close the connection using CTRL-Z)

If that works, try installing the MySQL GUI tools on your windows box and connect to the database using them. You will probably have to add your Windows IP address as an allowed root host in MySQL.

Finally, look at the the hosts file on the Windows machine, and on the Debian machine. An invalid hosts file can cause strange communications problems like what you are seeing. You can post the hosts files if the error is not obvious.

One more thought - try turning off IPv6 in Windows 7 - it is on by default.

JBoss In Action
Mike Clarkson

Joined: Dec 31, 2009
Posts: 4
it works now, for some reason denyhosts had my internal ip for my windows machine blocked. i removed it and all is working.

thanks for all the help! this community seems pretty awesome so far!

Don't get me started about those stupid light bulbs.
subject: Communications link failure with MySQL
Similar Threads
Problem connecting eclipse to mysql database with hibernate
applet socketpermissions
applet Mysql connection
mysql connection problem
Error connecting on MySQL