Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a4AXI-00016Q-D9 for pgsql-jdbc@arkaria.postgresql.org; Wed, 02 Dec 2015 16:45:44 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a4AXH-0006IX-W9 for pgsql-jdbc@arkaria.postgresql.org; Wed, 02 Dec 2015 16:45:44 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1a4AXH-0006IR-H9 for pgsql-jdbc@postgresql.org; Wed, 02 Dec 2015 16:45:43 +0000 Received: from mail-wm0-x232.google.com ([2a00:1450:400c:c09::232]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a4AXD-0007lc-TU for pgsql-jdbc@postgresql.org; Wed, 02 Dec 2015 16:45:43 +0000 Received: by wmec201 with SMTP id c201so66343814wme.1 for ; Wed, 02 Dec 2015 08:45:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:message-id:date:to:mime-version; bh=SuNgSz72PK5/tQx4v/j8wQ8P/D8J9EqgkRUXhM2fbhA=; b=SH35wKrOHeIKd6SJGfPo8+pvpVcQYsHmD30eMApnHlMFMwtj9nEgS0vUXFJh7t7X+z itDVd/ay9N+2/4gzmnYbKh/ghCZfbdlW3NrvjGVTgmSzMEJQXzngCGyBleI6viAgAZak VNsZs4qC9UC10UEJ/UuDSBNxor/+T5OMEII+3P0eNEX9SzF1SaFDnRR3AryyZHqF4blO 8yLIBfew5fF7LXB7OU8ojpBM9eq0AQxYwdam4FReRDPwBotd1WJLFIc2/r3xWqnPrcgM 13aXrIvlbfBDbP+NrlqIPm03H84f/hEXAp7XwYGwc67YvL4HBqiJEe2SQA7jCifEEseM O5PQ== X-Received: by 10.194.108.103 with SMTP id hj7mr6527515wjb.143.1449074739288; Wed, 02 Dec 2015 08:45:39 -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 t2sm33539476wmt.1.2015.12.02.08.45.37 for (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Dec 2015 08:45:38 -0800 (PST) From: Nuno Zimas Content-Type: multipart/alternative; boundary="Apple-Mail=_975B7211-2610-41B9-BAF2-0A5EE042DE8E" Subject: user can't access own database after creation Message-Id: <25B91293-CCF8-42D9-B4ED-19DF36AA881C@gmail.com> Date: Wed, 2 Dec 2015 16:45:37 +0000 To: pgsql-jdbc@postgresql.org Mime-Version: 1.0 (Mac OS X Mail 9.1 \(3096.5\)) 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=_975B7211-2610-41B9-BAF2-0A5EE042DE8E Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 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&s= sl=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#=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. host all all 10.10.10.99/32 trust 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, http://pastebin.com/ZZb5a55W 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 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); //properties.put(PersistenceUnitProperties.JDBC_URL, = appProfile.getURI()); The full version of the file can be found here: = https://github.com/flabser/2next/blob/master/src/com/flabser/dataengine/Da= tabaseCore.java Thank you very much for reading. Nuno.= --Apple-Mail=_975B7211-2610-41B9-BAF2-0A5EE042DE8E Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=us-ascii
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=3Dpasswo= rd&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

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(PersistenceUnitProperties.JDBC_DRIVER, = driver);
          =       properties.put(PersistenceUnitProperties.JDBC_USER, = dbLogin);
          =       = properties.put(PersistenceUnitProperties.JDBC_PASSWORD, = dbPwd);
          =       = //properties.put(PersistenceUnitProperties.JDBC_PROPERTY, = dbPwd);

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


The full version of the file can be found here:

Thank you very much = for reading.

Nuno.
= --Apple-Mail=_975B7211-2610-41B9-BAF2-0A5EE042DE8E--