Re: [GENERAL] DriverManager.getConnection() fails sometimes but succeeds other times

From: "Marin Dimitrov" <marin(dot)dimitrov(at)sirma(dot)bg>
To: "Enote" <sys(at)yahoo(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: [GENERAL] DriverManager.getConnection() fails sometimes but succeeds other times
Date: 2002-03-20 12:17:10
Message-ID: 000801c1d009$297dfc10$9b0e32d4@sirma.bg
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-jdbc


> Michael E Mercer <mmercer(at)lboard(dot)com> wrote in message
news:<3C960A14(dot)B45611B(at)lboard(dot)com>...
> > Hello,
> >
> > I have a java program running as root and tries to connect to database
> > as user
> > 'A' with password 'A'.
> >
> > The pg_hba.conf is set to allow users to connect from any host with md5
> > authentication.
> >
> > The java program uses the same method to connect to the database,
> > however
> > sometimes authentication
> > succeeds and sometimes it fails. The user and password are hard coded,
> > so there
> > is no probable error there.
> >

I have the very same problem here - Postgres 7.2 on RH 7.2, JDBC driver is
[PostgreSQL 7.2b5 JDBC2] from the official site

getConnection seems to fail when called after some period of inactivity, but
if a subsequent attempt is made then it is successful

a sample code would look like:

Connection conn =
DriverManager.getConnection("jdbc:postgresql://192.168.128.208:5432/gate09?u
ser=gateadmin&password=gate");

the pg_hba.conf contains:

=============
host all 192.168.128.42 255.255.255.255 md5
host all 212.50.14.155 255.255.255.255 md5
=============

...where the above are the two IPs of my machine (the JDBC client)

the log file contains:

==========
FATAL 1: Password authentication failed for user "gateadmin"
DEBUG: pq_recvbuf: recv() failed: Connection reset by peer
==========

any hints?

thanx,

Marin

----
"...what you brought from your past, is of no use in your present. When
you must choose a new path, do not bring old experiences with you.
Those who strike out afresh, but who attempt to retain a little of the
old life, end up torn apart by their own memories. "

In response to

Browse pgsql-general by date

  From Date Subject
Next Message TPCCUVA 2002-03-20 12:55:43 problem with begin transacction.
Previous Message snpe 2002-03-20 12:05:36 Distributed databases and replication in postgresql 7.3 ?

Browse pgsql-jdbc by date

  From Date Subject
Next Message Marin Dimitrov 2002-03-20 15:24:47 BLOBs
Previous Message Dave Cramer 2002-03-20 11:01:22 Re: "No results were returned by the query" exceptions