Re: jdbc connection - UnknownHostException

Lists: pgsql-jdbc
From: Yann Calderara <cy(at)netlabs(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: jdbc connection - UnknownHostException
Date: 2003-12-22 23:59:55
Message-ID: 20031223005955.78fa81b6.cy@netlabs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hello list,
Can anyone help me with this issue?
I'm trying to write a bean (used within the struts framwork) that gives some methods about managing the database, located on http://myhost1.org. After some attempts, the connection succeded, but when a tried it again, I received an UnknownHostException. I've then tried after many things to connect through the db with another alias, http://myhost2.org (which is the very same ip than myhost1.org), and it works a few times.

I've then written a small test class, which looks very like what is in the bean, to connect on a postgresql:

Class.forName("org.postgresql.Driver"); //load the driver
db=DriverManager.getConnection("jdbc:postgresql://myhost1.org:5432/dbname", "user", "pwd");
//...
db.close();

and it works fine, no exceptions (loading driver and connecting ok).
But in the same time, the connection in the bean does not succeed any more...

The driver is always correctly loaded.
What am I missing? thanks for any answer :)
yann

--
Yann Calderara <cy(at)netlabs(dot)org>
OpenPGP: 8E31751C / 26EA EDA3 1671 CCCF 815D 89A4 307D 4B8E 8E31 751C


From: "Nick Fankhauser" <nickf(at)ontko(dot)com>
To: "Yann Calderara" <cy(at)netlabs(dot)org>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: jdbc connection - UnknownHostException
Date: 2003-12-23 00:57:39
Message-ID: NEBBLAAHGLEEPCGOBHDGMEMDKDAA.nickf@ontko.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Yann-

Is it possible that some security software (firewall or such) is running on
myhostn.org which might regard activity on port 5432 suspicious & close the
connection? Sometimes when connections seem to work & then quickly stop,
this is the cause.

-Nick

> -----Original Message-----
> From: pgsql-jdbc-owner(at)postgresql(dot)org
> [mailto:pgsql-jdbc-owner(at)postgresql(dot)org]On Behalf Of Yann Calderara
> Sent: Monday, December 22, 2003 7:00 PM
> To: pgsql-jdbc(at)postgresql(dot)org
> Subject: [JDBC] jdbc connection - UnknownHostException
>
>
> Hello list,
> Can anyone help me with this issue?
> I'm trying to write a bean (used within the struts framwork) that
> gives some methods about managing the database, located on
http://myhost1.org. After some attempts, the connection succeded, but when a
tried it again, I received an UnknownHostException. I've then tried after
many things to connect through the db with another alias, http://myhost2.org
(which is the very same ip than myhost1.org), and it works a few times.

I've then written a small test class, which looks very like what is in the
bean, to connect on a postgresql:

Class.forName("org.postgresql.Driver"); //load the driver
db=DriverManager.getConnection("jdbc:postgresql://myhost1.org:5432/dbname",
"user", "pwd");
//...
db.close();

and it works fine, no exceptions (loading driver and connecting ok).
But in the same time, the connection in the bean does not succeed any
more...

The driver is always correctly loaded.
What am I missing? thanks for any answer :)
yann

--
Yann Calderara <cy(at)netlabs(dot)org>
OpenPGP: 8E31751C / 26EA EDA3 1671 CCCF 815D 89A4 307D 4B8E 8E31 751C


From: Yann Calderara <cy(at)netlabs(dot)org>
To: <nickf(at)ontko(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: jdbc connection - UnknownHostException
Date: 2003-12-23 09:51:29
Message-ID: 20031223105129.11c92cc8.cy@netlabs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Nick,

Thanks for your answer. But no, no security application can be disturbing that connection. Strange is that it worked for myhost2 and no more with myhost1...
When it worked, it worked great (different select).
If postgresql wasn't accepting connections (pg configuration / firewall), should I not receive another exception than this UnknownHostException?

yann

On Mon, 22 Dec 2003 19:57:39 -0500
"Nick Fankhauser" <nickf(at)ontko(dot)com> wrote:

> Yann-
>
> Is it possible that some security software (firewall or such) is running on
> myhostn.org which might regard activity on port 5432 suspicious & close the
> connection? Sometimes when connections seem to work & then quickly stop,
> this is the cause.
>
> -Nick
>
> > -----Original Message-----
> > From: pgsql-jdbc-owner(at)postgresql(dot)org
> > [mailto:pgsql-jdbc-owner(at)postgresql(dot)org]On Behalf Of Yann Calderara
> > Sent: Monday, December 22, 2003 7:00 PM
> > To: pgsql-jdbc(at)postgresql(dot)org
> > Subject: [JDBC] jdbc connection - UnknownHostException
> >
> >
> > Hello list,
> > Can anyone help me with this issue?
> > I'm trying to write a bean (used within the struts framwork) that
> > gives some methods about managing the database, located on
> http://myhost1.org. After some attempts, the connection succeded, but when a
> tried it again, I received an UnknownHostException. I've then tried after
> many things to connect through the db with another alias, http://myhost2.org
> (which is the very same ip than myhost1.org), and it works a few times.
>
> I've then written a small test class, which looks very like what is in the
> bean, to connect on a postgresql:
>
> Class.forName("org.postgresql.Driver"); //load the driver
> db=DriverManager.getConnection("jdbc:postgresql://myhost1.org:5432/dbname",
> "user", "pwd");
> //...
> db.close();
>
> and it works fine, no exceptions (loading driver and connecting ok).
> But in the same time, the connection in the bean does not succeed any
> more...
>
> The driver is always correctly loaded.
> What am I missing? thanks for any answer :)
> yann
>
>
> --
> Yann Calderara <cy(at)netlabs(dot)org>
> OpenPGP: 8E31751C / 26EA EDA3 1671 CCCF 815D 89A4 307D 4B8E 8E31 751C
>
>
>
>

--
Yann Calderara <cy(at)netlabs(dot)org>
OpenPGP: 8E31751C / 26EA EDA3 1671 CCCF 815D 89A4 307D 4B8E 8E31 751C


From: "Nick Fankhauser" <nickf(at)ontko(dot)com>
To: "Yann Calderara" <cy(at)netlabs(dot)org>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: jdbc connection - UnknownHostException
Date: 2003-12-23 11:52:34
Message-ID: NEBBLAAHGLEEPCGOBHDGAEOBKDAA.nickf@ontko.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

> should I not receive another exception than this
> UnknownHostException?

Good point. I'd expect a different error message, but thought it was
possible that unresponsiveness might result in this one. I was keying in
more on the inconsistent behavior.

Now that I think about it, a more likely possibility is that the DNS server
responsible for resolving myhost1.org is not responding quickly, so the
lookup times out in some cases. what happens if you try to replace
"myhost1.org" with the actual IP address?

-Nick


From: Yann Calderara <cy(at)netlabs(dot)org>
To: <nickf(at)ontko(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: jdbc connection - UnknownHostException
Date: 2003-12-24 14:13:51
Message-ID: 20031224151351.43e58571.cy@netlabs.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

> Now that I think about it, a more likely possibility is that the DNS server
> responsible for resolving myhost1.org is not responding quickly, so the
> lookup times out in some cases. what happens if you try to replace
> "myhost1.org" with the actual IP address?

You are right: it works with the ip address. I'm still not sure it was a problem with the dns resolution, but the fact is, I didn't have any new UnknownHostException since 1-2 days...
Thanks Nick for your help, and if you have another idea, let me know :)

yann

--
Yann Calderara <cy(at)netlabs(dot)org>
OpenPGP: 8E31751C / 26EA EDA3 1671 CCCF 815D 89A4 307D 4B8E 8E31 751C