I was getting the following error when trying to connect to my MySQL database running on localhost using the JDBC MySQL Connector/J:

org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Communications link failure due to underlying exception: 

** BEGIN NESTED EXCEPTION ** 

java.net.ConnectException
MESSAGE: Connection refused

The user I was trying to connect with had all the right permissions. The problem was, my hosts file didn't have an IPv4 entry for localhost. Once I added that it worked fine:

# /etc/hosts
::1     localhost.localdomain   localhost
127.0.0.1 localhost.localdomain localhost


CategoryLinux CategoryProgramming CategoryDatabase

MySQLConnectorJ (last edited 2007-04-11 12:08:48 by DavidKeen)