Re: problem with jdbc connection to postgesql

From: Paul Thomas <paul(at)tmsl(dot)demon(dot)co(dot)uk>
To: "pgsql-general (at) postgresql (dot) org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: problem with jdbc connection to postgesql
Date: 2004-02-03 18:37:30
Message-ID: 20040203183730.A23708@bacon
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 03/02/2004 15:45 Phil Campaigne wrote:
> Hi All,
> I am seting up my web app with a tomcat/postgresql hosting service. From
> my psql client I type psql and then I am asked for my password. This
> logs me into my hosted database just fine.
>
> However, I can't log on from my webapp to the database thru jdbc like I
> could when my webapp/Tomcat/postgresql were on my local machine. The
> jdbc class only has a method with 3 parameters, url, user, password
> parameters. The hosting server is giving me the following error message:
> >Stack Trace:
>
> >java.sql.SQLException: FATAL 1: Password authentication failed
> for >user "xxxxxx"
>
> >So, it looks like it is trying to connect using username xxxxxx,
> >not password yyyyyy.
>
> I'm using the DriverManager.getConnection(url, user, password) method in
> my connection class.
>
> jdbc:postgresql://database.domain.org/databasename
>
> username: xxxxxx
> password: yyyyyy
>
> It seems to be confused by the presence of the extra parameter 'user'. I
> believe that the postgresql database wants just the password. How do I
> give it just the url and password. There is no getConnection method on
> the DriverManager classd with just url and password?
>
> Has anyone else experienced this problem? Any ideas?

Well obviously you can't have a password without a user which why there is
no such method signature. Make sure that:

a) the postmaster is listening on tcp/ip port 5432 (it looks like it else
you would probably get a connect failure)

b) your user is allowed to connect to the database using tcp/ip (check
pg_hba.conf)

c) you are using the correct password for the user.

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Eisentraut 2004-02-03 18:52:57 Re: Anyone has nls activated on Mac OS X?
Previous Message Craig Addleman 2004-02-03 18:16:07 Re: Pl/tcl auto-load problem