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?