Re: Password authentication working with psql, but fails with jdbc for me - Mailing list pgsql-jdbc

From Paul Thomas
Subject Re: Password authentication working with psql, but fails with jdbc for me
Date
Msg-id 20030918184558.A31677@bacon
Whole thread Raw
In response to Password authentication working with psql, but fails with jdbc for me  ("Gerald Dalley" <dalleyg@MIT.EDU>)
Responses Re: Password authentication working with psql, but fails with jdbc for me  ("Gerald Dalley" <dalleyg@MIT.EDU>)
List pgsql-jdbc
On 18/09/2003 17:15 Gerald Dalley wrote:
> I have setup a system with postgres 7.3.4-5 on Debian and am attempting
> to
> access a database from Java.  When I use trust permissions, e.g. I have
> the
> following in my pg_hba.conf file:
>     host all <theuser> <ip-range> <ip-mask> trust
> everything works fine (with values in angled brackets replaced as
> appropriate of course).  I can access the database both through psql and
> with Java.  If I modify pg_hba.conf to use any kind of password
> authentication (other than Kerberos, which isn't supported in the JDBC
> drivers), e.g. by using any one of the following lines
>     host all <theuser> <ip-range> <ip-mask> password
>     host all <theuser> <ip-range> <ip-mask> crypt
>     host all <theuser> <ip-range> <ip-mask> md5
> then psql asks for a password and works properly, but I get the following
> error for the JDBC drivers:
>     Password authentication failed for user "<theuser>"
>     at org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection
> AbstractJdbc1Connection.java:202)
>     at org.postgresql.Driver.connect(Driver.java:122)
>
> I get the same results from multiple machine with different JVMs and by
> trying out pg73jdbc1.jar, pg73jdbc2.jar, and pg73jdbc3.jar (by adding
> them,
> one at a time, to the classpath).  In my postgresql.conf file, I do have
> "tcpip_socket=true".
>
> Most of the FAQs and discussions I've found on the topic point to
> classpath
> issues.  As far as I can tell though, I'm using the classpath correctly
> since everything works fine in trust mode.
>
> Any ideas what I could be doing incorrectly?

First, don't thrown by "AbstractJdbc1Connection". The JDBC2 and JDBC3
classes mostly extend the JDBC1 classes. How did you create the db user?
Maybe you got the password wrong or possibly no password at all. Are your
psql connections from the same machine because if they IRC, psql will
connect using unix sockets instead of tcp/ip so the host lines will not be
used.

I'm sure it must just some simple configuration error as I've been
successfully connecting with userid/password since version 7.1.

HTH

--
Paul Thomas
+------------------------------+---------------------------------------------+
| Thomas Micro Systems Limited | Software Solutions for the Smaller
Business |
| Computer Consultants         |
http://www.thomas-micro-systems-ltd.co.uk   |
+------------------------------+---------------------------------------------+

pgsql-jdbc by date:

Previous
From: "Gerald Dalley"
Date:
Subject: Password authentication working with psql, but fails with jdbc for me
Next
From: "Nick Fankhauser"
Date:
Subject: Re: Password authentication working with psql, but fails with jdbc for me