Connection problems with jdbc

From: Andrew Brunette <brunette(dot)andrew(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Connection problems with jdbc
Date: 2010-04-27 23:38:18
Message-ID: h2s326b1ea31004271638k8fa38c3cp9a8db7af4f28c69f@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-jdbc by date

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