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

pg_hba.conf reversed behaviour from 8.1.0beta3 -> 8.1.0 using JDBC

From: "Vidar Steen" <vidarsteen(at)hotmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: pg_hba.conf reversed behaviour from 8.1.0beta3 -> 8.1.0 using JDBC
Date: 2005-11-25 16:45:09
Message-ID: BAY109-F3275A016CEF6CD05811200CE570@phx.gbl (view raw or flat)
Lists: pgsql-novice
I'm developing a 'datarepository' to an application that other people are 
working on.
My app will be a java app with no gui pipeing requests for fetching/storing 
of data to/from postgresql.
In early testing i've run postgresql8.1.0beta3 on a linux box and the java 
app on a windows box
connecting using postgresql-8.1-404.jdbc3.jar . Opening up the windows box 
ip in pg_hba.conf enabled me to
connect just fine... eg.
>>host target vist trust

--Connection to PostgreSQL 8.1.0 successful.
--update with preparedStatement of 1000 rows took 5 sec.

Thinking that i might get better performance if I ran my java agent localy 
on the same box as
postgresql I deployed it there and to my surprise I couldn't connect to pg.
No matter what i entered into pg_hba .conf i couldn't connect running the 
agent locally but remotely worked just fine.
Fiddling with entrys in pg_hba.conf AND 'reload':ing pg made the REMOTE 
application able/unable to connect as expected, but no amount of effort made 
it possible to connect running it on the same box.

This morning I moved from 8.1beta3 to 8.1.0 and to my surprise the scenario 
is now completly inverse.
Now I can ONLY connect to pg from my java app running on the same box as pg 
,but not from anywhere else
no matter what I enter into pg_hba.conf. And YES I reload pg after each mod 
to pg_hba, that bit me more than once too :)

I've tried a lot of combinations i pg_hba listed below. not at the same time 
though as if I read and understand the doc correctly
the first rule that excludes a connection is the one being used.
from the 8.1.0 Documentation
There is no fall-through or backup: if one record
is chosen and the authentication fails, subsequent records are not 
considered. If no record matches,
access is denied.
Even entering
host all all trust
doesn't do the trick.

If you have any idea about whats going on please drop a line because i'm at 
whits end here having fiddled with this for almost two full days now.

Below are printouts from my first test app.
To repeat myself the outcome were exactly inverse using 8.1.0 and 8.1.0beta3 
with the same exception was thrown in both cases.

Case 1:

connecting with Java 1.5_05 from another network.
--Reading propsfile: 
--> rowsToInsert:1000
--> //dbHost:localhost
--> db:target
--> dbPort:5432
--> dbHost:
--> username:vist
--org.postgresql.util.PSQLException: Connection refused. Check that the 
hostname and port are correct and that the postmaster is accepting TCP/IP

connections.--	at 
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(	at

org.postgresql.core.ConnectionFactory.openConnection(	at

org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(	at

org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(	at

org.postgresql.jdbc3.Jdbc3Connection.<init>(	at 
org.postgresql.Driver.makeConnection(	at

org.postgresql.Driver.connect(	at 
Case 2:

java 1.4.2 on the same linux box as pg.
[vist(at)florens jabba]$ env CLASSPATH=. java -cp 
./postgresql-8.1-404.jdbc3.jar se.mycompany.jabba
--user.dir: /home/vist/jabba
--Reading propsfile: /home/vist/
--> //dbHost:florens
--> dbPort:5432
--> db:target
--> rowsToInsert:1000
--> username:vist
--> dbHost:
--Connection to PostgreSQL 8.1.0 successful.
--update with preparedStatement of 1000 rows took 5 sec.
--commit update with preparedStatement of 1000 rows took 4 sec.
--update with insert into allan values (314,'insert','lkcxs','cssclcn')  
1000 times took 2 sec.
--update with modded sqlInsert in for loop 1000 times took 2 sec.

end printout

target=> select version();
PostgreSQL 8.1.0 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.0 
20050519 (Red Hat 4.0.0-8)
(1 row)

pgsql-novice by date

Next:From: manjusri schuitDate: 2005-11-25 22:33:30
Subject: Re: Problem Upgrading from 8.0 to 8.1 (WinXP) ...not still solved!!
Previous:From: John KollerDate: 2005-11-25 16:38:37
Subject: Re: Schemas, databases, and backups

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