pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Connection problems with jdbc
2+ messages / 2 participants
[nested] [flat]

* Connection problems with jdbc
@ 2010-04-27 23:38  Andrew Brunette <brunette.andrew@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Andrew Brunette @ 2010-04-27 23:38 UTC (permalink / raw)
  To: pgsql-jdbc

Hi, I'm new to postgres, and am having some issues getting started.  I am
trying to set up a java based dataload to postgres.  I've done the following
things:

1) initialized postgres's db
2) created a database 'dev'
3) created a user, 'abrunette'.  I created the user as a superuser.
4) created a table, 'foo', using a standard create statement
5) created a password for the user.

I can log into postgres as abrunette.  I created the table as abrunette, and
can display it fine.

I then tried to configure my loader routine to access the database, using
the following code:

private void preparePostGreSQLDB() throws Exception {
        // Using simple URL for now, will need to be updated to work with
remote db server
        String sqlurl = "jdbc:postgresql:" + params.dbName;


        try {
            // Attempt to connect to a sql driver.
            Class.forName("org.postgresql.Driver");
            conn = DriverManager.getConnection(sqlurl,
params.dbUser.toString(), params.dbPassword.toString());
            conn.setAutoCommit(true);
        }
        catch(SQLException dre) {
            logger.info(dre.getMessage());
            throw new Exception ("Error in connecting to database using " +
sqlurl);
        }
        catch(Exception io) {
            logger.info(io.getMessage());
            throw new Exception ("Non SQL error in connecting to database
using " + sqlurl);
        }
    }

sqlurl ends up with the value "jdbc:postgresql:dev".  The username is
abrunette, and the password is correct as well.

When I run this, I get the message, "FATAL: Ident authentication failed for
user "abrunette"".  Testing seems to indicate that this message could come
from a variety of sources.  Can anyone suggest what I might be doing wrong?

I have experimented with different forms of the URL with no change to the
results.  Changing the database name doesn't change the result either, so I
suspect I've got something more fundamental wrong.

Any help will be greatly appreciated.  Thanks.

Andrew

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Connection problems with jdbc
@ 2010-04-28 00:22  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Andrew Brunette <brunette.andrew@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2010-04-28 00:22 UTC (permalink / raw)
  To: Andrew Brunette <brunette.andrew@gmail.com>; +Cc: pgsql-jdbc

Andrew Brunette <brunette.andrew@gmail.com> writes:
> When I run this, I get the message, "FATAL: Ident authentication failed for
> user "abrunette"".  Testing seems to indicate that this message could come
> from a variety of sources.  Can anyone suggest what I might be doing wrong?

The server's pg_hba.conf is set to demand ident authentication, not
password authentication, and your client code is not actually running
as user abrunette (or at least isn't connecting over a pathway that
would allow that to be determined reliably).

See
http://www.postgresql.org/docs/8.4/static/client-authentication.html
for info about reconfiguring to use password authentication.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2010-04-28 00:22 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-04-27 23:38 Connection problems with jdbc Andrew Brunette <brunette.andrew@gmail.com>
2010-04-28 00:22 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox