pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
(Yet another) unable to connect w/ JDBC via hostname
2+ messages / 2 participants
[nested] [flat]

* (Yet another) unable to connect w/ JDBC via hostname
@ 1999-07-27 17:45 Mark Dzmura <mdz@phalanx.phalanx.net>
  1999-07-28 12:01 ` Re: [INTERFACES] (Yet another) unable to connect w/ JDBC via hostname Herouth Maoz <herouth@oumail.openu.ac.il>
  0 siblings, 1 reply; 2+ messages in thread

From: Mark Dzmura @ 1999-07-27 17:45 UTC (permalink / raw)
  To: pgsql-interfaces

Help!

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.

I have searched the postgresql [INTERFACE] mailing list archives and
found some related problems, but the answers seem to point to the
pg_hba.conf file - and I believe I have uncommented and modified a line
in the default file which should give access to hosts on my LAN.

On to my problem:

For example, I if I use any of the following URL's, running the client on the same
machine which hosts the database:

 jdbc:postgresql:db1
 jdbc:postgresql://127.0.0.1/db1
 jdbc:postgresql://localhost/db1

it WORKS!!

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

 jdbc:postgresql://enterprise.foobar.com/db1
 jdbc:postgresql://enterprise/db1

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)

--------------------------------
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:

   enterprise
   enterprise.foobar.com

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   208.205.224.0   255.255.255.0     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,
              user,
              pass);

 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 ??

Thanks,
Mark Dzmura

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






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

* Re: [INTERFACES] (Yet another) unable to connect w/ JDBC via hostname
  1999-07-27 17:45 (Yet another) unable to connect w/ JDBC via hostname Mark Dzmura <mdz@phalanx.phalanx.net>
@ 1999-07-28 12:01 ` Herouth Maoz <herouth@oumail.openu.ac.il>
  0 siblings, 0 replies; 2+ messages in thread

From: Herouth Maoz @ 1999-07-28 12:01 UTC (permalink / raw)
  To: Mark Dzmura <mdz@phalanx.phalanx.net>; pgsql-interfaces

At 20:45 +0300 on 27/07/1999, Mark Dzmura wrote:


> 4. The access file, pg_hba.conf contains the following line:
>
>    host         all   208.205.224.0   255.255.255.0     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,
>               user,
>               pass);
>
>  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.

1. Does identd run on your system?

2. Is the user you pass to the connection the same as the one that
   actually runs the program? This is important, because you asked
   Postgres to check by Ident that the user who tries to connect is
   indeed who he says he is (hence "sameuser").

   Since you didn't show the pg_hba.conf line that pertains to
   localhost (127.0.0.1), I assume that it uses 'trust'. This would
   explain the differences in behaviour.

BTW, if you use ident, you may as well pass an empty password. It is not
checked.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





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


end of thread, other threads:[~1999-07-28 12:01 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-07-27 17:45 (Yet another) unable to connect w/ JDBC via hostname Mark Dzmura <mdz@phalanx.phalanx.net>
1999-07-28 12:01 ` Herouth Maoz <herouth@oumail.openu.ac.il>

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