Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a4CHs-0006A5-Kg for pgsql-jdbc@arkaria.postgresql.org; Wed, 02 Dec 2015 18:37:56 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a4CHs-0000X6-74 for pgsql-jdbc@arkaria.postgresql.org; Wed, 02 Dec 2015 18:37:56 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a4CHK-0008Kg-Js for pgsql-jdbc@postgresql.org; Wed, 02 Dec 2015 18:37:22 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a4CHC-0007V5-Vu for pgsql-jdbc@postgresql.org; Wed, 02 Dec 2015 18:37:21 +0000 Received: by wmvv187 with SMTP id v187so268906860wmv.1 for ; Wed, 02 Dec 2015 10:37:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :message-id:references:to; bh=fu4QY8m1VDW+SEua2K7Lt9e0MHkkwVE9m4RIhiR8Aiw=; b=drmDLQsPoGWUjxxbAxWpFOAtd22E6HA0Xvsh3IT5PGglyXdOWwqzPaPiKRvpw9WtsZ tsPTtmtTWm4PphV5cdZKJMXnDqwOd/aLCcpcaRezxAmDdz2RchFqdHm68S713I7dvzTa CbbYRLYvBGhEnhMJN5VW/dApj4XpEC+CchEtbznN/a9RdmEKmpYuTJDdF2v1ftVEoivU 9Y851nX3z9EkYX052xKMRwPp3ehOGA59R/fuYK6KnFLJ3XczDWoSKUbEYP8BIphtaZDd TwiZ1uyZffp7mz9MRQtSMzBo9d3sAsrAhdYlTCuN40BfdFyvWyZ3R110HKskWQPtlykK wqEw== X-Received: by 10.28.150.7 with SMTP id y7mr7979064wmd.73.1449081433169; Wed, 02 Dec 2015 10:37:13 -0800 (PST) Received: from [192.168.1.66] (123.209.115.89.rev.vodafone.pt. [89.115.209.123]) by smtp.gmail.com with ESMTPSA id z17sm4003657wjq.1.2015.12.02.10.37.11 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Dec 2015 10:37:12 -0800 (PST) Content-Type: multipart/alternative; boundary="Apple-Mail=_F8F9DE27-71BF-485E-9D86-1F12561E7FEB" Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\)) Subject: Re: user can't access own database after creation From: Nuno Zimas In-Reply-To: Date: Wed, 2 Dec 2015 18:37:10 +0000 Cc: pgsql-jdbc@postgresql.org Message-Id: References: <25B91293-CCF8-42D9-B4ED-19DF36AA881C@gmail.com> To: "David G. Johnston" X-Mailer: Apple Mail (2.3096.5) X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org --Apple-Mail=_F8F9DE27-71BF-485E-9D86-1F12561E7FEB Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On 2 Dec 2015, at 18:32, David G. Johnston = wrote: >=20 > On Wed, Dec 2, 2015 at 9:45 AM, Nuno Zimas > wrote: > Dear everyone, >=20 > When attempting to access a PostgreSQL 9.4 database via JDBC on my = local Windows environment, everything works as intended. The database = user can access the database they have previously created from the admin = UI of the application. >=20 > Things take a turn for the worse when trying to perform the exact same = operation against any PostgreSQL 9.x backend running remotely on either = Ubuntu 12.04 / 14.04 / 15.04. The application log keeps spewing the = error below. >=20 > 2015-12-01 11:04:25,291 WARN [http-nio-8080-exec-5] log.Log4jLogger - = the entity manager of "Task" has not been initialized > 2015-12-01 11:04:25,292 ERROR [http-nio-8080-exec-5] log.Log4jLogger - = u90srlidr034307j user1 = jdbc:postgresql://10.10.10.97:5432/task0bg96qj544p0yu37 = > Changing the JDBC URL to = jdbc:postgresql://10.10.10.100:5432/db1?user=3Duser1&password=3Dpassword&s= sl=3Dtrue = = did not make any difference. >=20 > I have ascertained that postgres can log in via psql using the details = JDBC is suppilied with. Got similar results on PoatgreSQL 9.2, 9.3 and = 9.4 >=20 > root@Ubuntu-1204-precise-64-minimal ~ # sql -d db1 -U user1 -h = 10.10.10.97 -W > Password for user user1:=20 > psql (9.4.5, server 9.4.5) > SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256) > Type "help" for help. >=20 > db1=3D#=20 > Moreover, the auth method is set to trust on pg_hba.conf, meaning that = PostgreSQL will accept all kinds of auth methods from the specified = host. >=20 > host all all 10.10.10.99/32 trust >=20 > =E2=80=8B=E2=80=8BTo recap, once a user is added to the database = backend from the admin UI (via JDBC), they can create databases = themselves, but cannot access them. >=20 > I've compared the pg_hba.conf and postgresql.comf files on both my = localhost and the remote server and did not find anything outstanding. >=20 > The database JDBC is connecting to appears to have correct = permissions. >=20 > db1 | user1 | UTF8 | C | C | =3DTc/user1 = + > | | | | = | user1=3DCTc/user1 > The JDBC-PostreSQL driver used by the application is = postgresql-9.4-1201.jdbc4.jar. >=20 > You may find here a partial dump of the PostgreSQL log, which shows = queries performed when the error happens, > http://pastebin.com/ZZb5a55W >=20 > Finally the relevant portion of the Java source file where the = connection is defined looks as follows: >=20 > pool.initConnectionPool(driver, appProfile.getURI(), dbLogin, dbPwd); > Map properties =3D new HashMap(); > properties.put(PersistenceUnitProperties.JDBC_DRIVER, = driver); > properties.put(PersistenceUnitProperties.JDBC_USER, = dbLogin); > = properties.put(PersistenceUnitProperties.JDBC_PASSWORD, dbPwd); > = //properties.put(PersistenceUnitProperties.JDBC_PROPERTY, dbPwd); >=20 > //properties.put(PersistenceUnitProperties.JDBC_URL, = appProfile.getURI()); >=20 >=20 > The full version of the file can be found here: > = https://github.com/flabser/2next/blob/master/src/com/flabser/dataengine/Da= tabaseCore.java = >=20 > Thank you very much for reading. >=20 >=20 > =E2=80=8BI've read this twice and maybe I'm being dense but I see = nothing here that is readily actionable. Nor does it suggest a problem = with the JDBC driver. >=20 > =E2=80=8B"""=E2=80=8B > =E2=80=8BTo recap, once a user is added to the database backend from = the admin UI (via JDBC), they can create databases themselves, but = cannot access them. > """ > =E2=80=8B > You should try to organize and simplify you situation better, and = hopefully in so doing will find your problem. I'm doubting it has = anything to do with the driver and am not inclined to start debugging = your application from the limited information provided. Unless you are = referring to pgAdmin somewhere in here but if you are you should use its = proper name and not "admin UI=E2=80=9D=E2=80=8B. I don=E2=80=99t use any GUI to admin the postgresql, so by admin UI i = actually mean the admin interact of the Java application that is = generating the reported error. Cheers, Nuno. >=20 > Dave > =E2=80=8B --Apple-Mail=_F8F9DE27-71BF-485E-9D86-1F12561E7FEB Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
On 2 Dec 2015, at 18:32, David G. Johnston <david.g.johnston@gmail.com> wrote:

On Wed, Dec 2, 2015 = at 9:45 AM, Nuno Zimas <nzimas@gmail.com> wrote:
Dear = everyone,

When attempting to access a PostgreSQL 9.4 = database via JDBC on my local Windows environment, everything works as = intended. The database user can access the database they have previously = created from the admin UI of the application.

Things take a turn for the worse when = trying to perform the exact same operation against any PostgreSQL 9.x = backend running remotely on either Ubuntu 12.04 / 14.04 / 15.04. The = application log keeps spewing the error below.

2015-12-01 11:04:25,291 WARN  [http-nio-8080-exec-5] =
log.Log4jLogger =
- the entity manager of "Task" has not been initialized
2015-12-01 =
11:04:25,292 ERROR [http-nio-8080-exec-5] =
log.Log4jLogger =
- u90srlidr034307j user1 jdbc:postgresql://10.10.10.97:5432/task0bg96qj544p0yu37
Changing the JDBC URL to = jdbc:postgresql://10.10.10.100:5432/db1?user=3Duser1&password=3Dpassword&= ssl=3Dtrue did not = make any difference.

I have = ascertained that postgres can log in via psql using the details JDBC is = suppilied with. Got similar results on PoatgreSQL 9.2, 9.3 and = 9.4

root@Ubuntu-1204-precise-64-minimal =
~ # sql -d db1 -U =
user1 -h 10.10.10.97 -W
Password for user user1:=20
psql (9.4.5, server =
9.4.5)
SSL connection (cipher: DHE-RSA-AES256-SHA, =
bits: 256)
Type "help" for =
help.

db1=3D# 

Moreover, the auth method is set to trust on = pg_hba.conf, meaning that PostgreSQL will accept all kinds of auth = methods from the specified host.

host    all             all             =
10.10.10.99/32           =
trust

=E2=80=8B=E2=80=8B
To recap, once a = user is added to the database backend from the admin UI (via JDBC), they = can create databases themselves, but cannot access them.

I've compared the pg_hba.conf and = postgresql.comf files on both my localhost and the remote server and did = not find anything outstanding.

The database JDBC is connecting to appears to have correct = permissions.

db1        | user1         | UTF8      =
| C       | C     | =
=3DTc/user1       =
                     +
                         |                     |           =
|         |       | =
user1=3DCTc/user1

The JDBC-PostreSQL driver used by the application is = postgresql-9.4-1201.jdbc4.jar.

You may find here a partial dump of the PostgreSQL = log, which shows queries performed when the error happens,

Finally the relevant portion = of the Java source file where the connection is defined looks as = follows:

pool.initConnectionPool(driver, = appProfile.getURI(), dbLogin, dbPwd);
                Map<String, String> = properties =3D new HashMap<String, = String>();
          =       properties.put(PersistenceUni= tProperties.JDBC_DRIVER, driver);
    =             properties.put(PersistenceUni= tProperties.JDBC_USER, dbLogin);
    =             properties.put(PersistenceUni= tProperties.JDBC_PASSWORD, dbPwd);
                //properties.put(PersistenceU= nitProperties.JDBC_PROPERTY, dbPwd);

    =             //properties.put(PersistenceU= nitProperties.JDBC_URL, = appProfile.getURI());


The full version of the file can be found here:

Thank you very much = for reading.


=E2=80=8BI've read this twice and maybe = I'm being dense but I see nothing here that is readily actionable.  = Nor does it suggest a problem with the JDBC driver.

=E2=80=8B"""=E2=80=8B
=E2=80=8BTo recap, once a user is = added to the database backend from the admin UI (via JDBC), they can = create databases themselves, but cannot access them.
"""
=E2=80=8B
You should try to = organize and simplify you situation better, and hopefully in so doing = will find your problem.  I'm doubting it has anything to do with = the driver and am not inclined to start debugging your application from = the limited information provided.  Unless you are referring to = pgAdmin somewhere in here but if you are you should use its proper name = and not "admin = UI=E2=80=9D=E2=80=8B.

I don=E2=80=99t use any GUI to admin the = postgresql, so by admin UI i actually mean the admin interact of the = Java application that is generating the reported error.

Cheers,
Nuno.


Dave
=E2=80=8B
<= br class=3D"">= --Apple-Mail=_F8F9DE27-71BF-485E-9D86-1F12561E7FEB--