Thread: Database privileges

Database privileges

From
Diogo Martinez
Date:
Hi,

I've installed PostgreSQL 9.2.4, created a new database, created 1 new role and 1 table called t_test.
When I connect using psql with my new role and do a simple query (select * from t_test), it works fine, but when I connect using JDBC using the same role, I get a no privileges exception.

Can anybody help me, please?

Thanks,
Diogo

Re: Database privileges

From
"Day, David"
Date:

Probably the problem is your pg_hba.conf file which can filter access by IP address.

Your JDBC connection is perhaps via a hostname ( not localhost ) and your psql attachment was via local host.

A default installation only allows for localhost access.

 

e,g,

 

psql –h localhost  newdb    vs psql –h hostname

 

if one works and the other does not then adjust your pg_hba.conf file to allow access from other then localhost interface.

 

 

Rgds

 

 

Dave

 

From: pgsql-novice-owner@postgresql.org [mailto:pgsql-novice-owner@postgresql.org] On Behalf Of Diogo Martinez
Sent: Friday, April 19, 2013 12:22 PM
To: pgsql-novice@postgresql.org
Subject: [NOVICE] Database privileges

 

Hi,

 

I've installed PostgreSQL 9.2.4, created a new database, created 1 new role and 1 table called t_test.

When I connect using psql with my new role and do a simple query (select * from t_test), it works fine, but when I connect using JDBC using the same role, I get a no privileges exception.

 

Can anybody help me, please?

 

Thanks,

Diogo

Re: Database privileges

From
Tom Lane
Date:
Diogo Martinez <diogo.martinez@gmail.com> writes:
> I've installed PostgreSQL 9.2.4, created a new database, created 1 new role
> and 1 table called t_test.
> When I connect using psql with my new role and do a simple query (select *
> from t_test), it works fine, but when I connect using JDBC using the same
> role, I get a no privileges exception.

I'd bet JDBC isn't connecting to the same database, or maybe not even
the same server.  Also, are you getting a failure on connect, or when
trying to select?  If the former, maybe you need to fix pg_hba.conf
to allow JDBC to make a TCP connection (psql is probably coming in
via a unix-socket connection).

            regards, tom lane