Connection problems with jdbc - Mailing list pgsql-jdbc

From Andrew Brunette
Subject Connection problems with jdbc
Date
Msg-id h2s326b1ea31004271638k8fa38c3cp9a8db7af4f28c69f@mail.gmail.com
Whole thread Raw
Responses Re: Connection problems with jdbc  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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

pgsql-jdbc by date:

Previous
From: Hervé Hénoch
Date:
Subject: Postgresql8.4 + floats with jdbc driver postgresql-8.4-701.jdbc4.jar
Next
From: Oliver Jowett
Date:
Subject: Re: [Jdbc-commits] JDBC and real values returned by Postgres