Skip site navigation (1) Skip section navigation (2)

Help with JDBC access

From: Mark Dzmura <mdz(at)phalanx(dot)phalanx(dot)net>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Help with JDBC access
Date: 1999-07-27 17:32:03
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces

I am writing some software which uses JDBC to access SQL databases,
and am using Postgresql in the SQL database role.

I am unable to connect to a database using a "fully qualified"
URL to name the database.  For example, I if I use any of the following
URL's, running the client on the same machine which hosts the database:


it WORKS!!

However, if I try to use a fully-qualified address:


it fails with the following goofy error message:

 $ java com.foobar.jdbc.DBTest // comments added manually!
 loading driver!    // my output
 connecting to database  // my ouput
 Exception thrown!   // my output
 // following is driver output:
 Something unusual has occured to cause the driver to fail. Please report this exception: {1}
  at postgresql.Driver.connect(Compiled Code)
  at java.sql.DriverManager.getConnection(Compiled Code)
  at java.sql.DriverManager.getConnection(Compiled Code)
  at com.foobar.jdbc.DBTest.main(Compiled Code)

I have searched the postgresql [INTERFACE] archives and have seen some
related problems and answers - all of which seem to point to the pg_hba.conf
file.  However, I believe that I have the right line in that file to allow hosts
on my local network to access the database...

Now for some background:

1. I am using the following software:

 - Red Hat Linux 5.2 with kernel 2.2.7
 - Blackdown JDK 1.2.pre-beta-1
 - Postgresql 6.5 (latest version, not the one that came with Redhat)
 - Postgresql JDBC (jdbc6.5-1.2.jar)

2. Both of the host names used in the (failing) examples above
   are locally resolvable:


3. postgresql is running with the -i switch, enabling internet access

   $ ps ax | grep pg
    4811  ?  S    0:00 /usr/local/pgsql/bin/postmaster -i

4. The access file, pg_hba.conf contains the following line:

   host         all     ident     sameuser

   The intention is to allow any host on the local network to
   access any database using "ident" validation semantics (unix users).

5. The database was stopped and started after making these changes.

6. The following Java code tries to open a connection (in both
   the working and non-working cases):

   Connection db = DriverManager.getConnection(dbURL,

 The user and pass strings are a valid unix user and password,
 and the user has full access to the database in question.

 As mentioned above, This call throws an exception if dbURL is
 fully qualified (even if the machine name is the localhost),
 but NOT if it refers to a local database.

Any ideas ????

Mark Dzmura

)))) This email routed via a wireless gateway!! ((((

pgsql-interfaces by date

Next:From: Mark DzmuraDate: 1999-07-27 17:45:46
Subject: (Yet another) unable to connect w/ JDBC via hostname
Previous:From: Jonathan davisDate: 1999-07-27 15:46:28
Subject: Re: [INTERFACES] libpq problem

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group