Re: Exception "The connection attempt failed." (didn't find

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Pedro n/a <napalmblood(at)hotmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Exception "The connection attempt failed." (didn't find
Date: 2005-04-08 23:02:26
Message-ID: 42570D82.5070201@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Pedro n/a wrote:

> I'm quite new at java and I was just following a tutorial when I bumped
> with a horrible exception. [...]

> Caused by: java.net.UnknownHostException: localhost
> at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:153)

This is the underlying problem. If you do not specify a host to connect
to, the JDBC driver defaults to connecting to localhost, but for some
reason your system cannot resolve localhost.

The solution is to fix hostname resolution on your system. I can't give
you any suggestions as to how to do this as you didn't say anything
about the OS that you are using, but something is pretty broken if you
can't resolve localhost.

A workaround might be to provide an explicit IP address in the driver
URL, e.g. instead of 'jdbc:postgresql:databasename' use something like
'jdbc:postgresql://127.0.0.1/databasename'.

-O

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Kris Jurka 2005-04-08 23:04:16 Re: Version 8.0-310 and PreparedStatement.getParameterMetaData()
Previous Message Pedro n/a 2005-04-08 20:26:17 Exception "The connection attempt failed." (didn't find anything elsewhere)