Thread: Can't connect to Postgres with JDBC

Can't connect to Postgres with JDBC

From
Brian Cross
Date:
Hi,

          I'm trying to connect to my postgres database(that came with RedHat
5.0) with an applet using JDBC.  The driver seems to be loading fine, but I
receive this error when starting the applet:

java.sql.SQLException: Failed to authenticate client as Postgres user 'bscross'
using the default authentication type: be_recvauth: host-based authentication
failed.

The bscross user is both a system user and one I created in postgres.
Do I need to change the authentication type, and if so what does it need to be?

I have read every FAQ and HOWTO I could find with no luck.  I would be forever
in debt if someone could help me out with this.  Thanks!

--Brian Cross.

Re: [INTERFACES] Can't connect to Postgres with JDBC

From
Peter T Mount
Date:
On Mon, 19 Jan 1998, Brian Cross wrote:

> Hi,
>
>           I'm trying to connect to my postgres database(that came with
> RedHat 5.0) with an applet using JDBC.  The driver seems to be loading
> fine, but I receive this error when starting the applet:
>
> java.sql.SQLException: Failed to authenticate client as Postgres user
> 'bscross' using the default authentication type: be_recvauth: host-based
> authentication failed.
>
> The bscross user is both a system user and one I created in postgres.
> Do I need to change the authentication type, and if so what does it
> need to be?
>
> I have read every FAQ and HOWTO I could find with no luck.  I would be
> forever in debt if someone could help me out with this.  Thanks!

Ok, there are three things that can stop an applet from connecting, and
you have hit the one which affects all clients, not just jdbc.

The file $PGDATA/pg_hba.conf contains a list of hosts that are allowed
access to any database. What is happening is that your web browser is
attempting to access the database from an ip address/mask not defined in
that file. Full instructions are included inside the file.

The other two are where the applet is downloaded from one host, and the
database is on another. This is not possible, and throws a
SecurityException.

The third one is where the browser doesn't support JDK 1.1

Anyhow, when it says about "Host based authentication", the first place to
look in is pg_hba.conf

PS: Another test is (if you are running the applet from the same machine
as the database), to try the url with both your hostname, and localhost.
I'd bet you are using your host name, and it works with localhost. If so,
then pg_hba.conf is where your problem is.

--
Peter T Mount  petermount@earthling.net or pmount@maidast.demon.co.uk
Main Homepage: http://www.demon.co.uk/finder
Work Homepage: http://www.maidstone.gov.uk Work EMail: peter@maidstone.gov.uk