MySQL Java Connector Problem on Windows Vista

I’ve just been setting up Eclipse for Stripes development on my home PC and hit a problem connecting to the database. I haven’t seen this on any of my Windows XP machines and it seems to be specific to Windows Vista, which was bundled with the PC.

Versions in use are:

  • Windows Vista Home Basic
  • MySQL Server Community Edition 5.1.37
  • Eclipse JEE Galileo (based on Eclipse 3.5)
  • JDK 1.6 Update 16
  • JARs: mysql-connector-java-5.1.6-bin.jar, ibatis-2.3.0.677.jar

I tried re-installing MySQL with User Account Control turned off, and verified that it wasn’t being blocked by the firewall. Still no joy.

Then I found this thread on CodeRanch which suggests that the problem is something to do with resolving localhost. So I checked c:/windows/system32/drivers/etc/hosts and found this:

::1             localhost

It isn’t clear why the standard loopback IP address isn’t included, but adding it back in fixes the problem (also see Microsoft KB article):

127.0.0.1       localhost
::1             localhost

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: