Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1a4DVT-0001Tz-RJ for pgsql-jdbc@arkaria.postgresql.org; Wed, 02 Dec 2015 19:56:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1a4DVT-0000G1-DP for pgsql-jdbc@arkaria.postgresql.org; Wed, 02 Dec 2015 19:56:03 +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 1a4DUw-0007bZ-MT for pgsql-jdbc@postgresql.org; Wed, 02 Dec 2015 19:55:30 +0000 Received: from mail-wm0-x22d.google.com ([2a00:1450:400c:c09::22d]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1a4DUt-0003Sx-D3 for pgsql-jdbc@postgresql.org; Wed, 02 Dec 2015 19:55:30 +0000 Received: by wmuu63 with SMTP id u63so229856450wmu.0 for ; Wed, 02 Dec 2015 11:55:25 -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=vAQ0XTqkqKyyoyuMFOXc/wd5xoQaCxrc1gLCzOvjkyE=; b=fv3DeJrwR7kLi8KPtsi513UVTPOYPeqh2Q/ffxyybI920SRjTInPek1CSHL2Tzo75W FvTSVpUuuGfxATfvW76yDMkZ/b7lRQ3hzCcBJ7Vm8znR1miJaWlAwXyqD+Hc+Dzb4qk5 PDhnq9adD3gZGBS9T9MoX3F5eH6dgk5TJ0e6WG1iq0V9H6VTAdihqhf1fmmXLf8D9RQ6 3xT7eHU8H5vzQPAuZ1j5RndQbPujQlwr3dJSnKUvfgrInOsS82lr3g6SvNw4PHPwVhWt 36LkAKTcVCsp9C5tPx4v+3KLn/jTZH44kSswilpFZWKTZZAT1265g2fnJ5nHFf0+CCE+ 1DTg== X-Received: by 10.28.46.206 with SMTP id u197mr43833068wmu.86.1449086125620; Wed, 02 Dec 2015 11:55:25 -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 i18sm4672740wmf.6.2015.12.02.11.55.23 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Dec 2015 11:55:24 -0800 (PST) Content-Type: multipart/alternative; boundary="Apple-Mail=_730307E2-399A-4D4C-8F6A-79C34AB9E035" 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 19:55:23 +0000 Cc: "David G. Johnston" , List Message-Id: References: <25B91293-CCF8-42D9-B4ED-19DF36AA881C@gmail.com> To: Dave Cramer X-Mailer: Apple Mail (2.3096.5) X-Pg-Spam-Score: -1.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=_730307E2-399A-4D4C-8F6A-79C34AB9E035 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 psql always connects successfully no matter what. As for JDBC, we get the same results with or without ssl=3Dtrue = explicitly appended to the URL. What truly baffles me is that ye exact same java application works with = no hiccups against a quasi-vanilla pgsql backend i=E2=80=99ve installed = on windows 10. So far, the only visible difference I found is in the values for = LC_COLLATE and LC_TYPE, which is V on the remote pgsql instances and = English_United States.1252 on the local pgsql instance. Not sure how tis would affect accessing the DBs, though. =20 > On 2 Dec 2015, at 19:14, Dave Cramer wrote: >=20 > One thing I noticed is that psql is connecting via SSL. >=20 > Have a look at the pg logs to see what the error is >=20 > Dave Cramer >=20 > davec@postgresintl.com > www.postgresintl.com > On 2 December 2015 at 13:37, Nuno Zimas > wrote: >=20 >> 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. >=20 > 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. >=20 > Cheers, > Nuno. >=20 >>=20 >> Dave >> =E2=80=8B >=20 >=20 --Apple-Mail=_730307E2-399A-4D4C-8F6A-79C34AB9E035 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 psql always connects successfully no matter what.
As for JDBC, we get the same results with or without ssl=3Dtrue= explicitly appended to the URL.
What truly baffles = me is that ye exact same java application works with no hiccups against = a quasi-vanilla pgsql backend i=E2=80=99ve installed on windows = 10.
So far, the only visible difference I found is = in the values for LC_COLLATE and LC_TYPE, which is V on the remote pgsql = instances and English_United States.1252 on the local pgsql = instance.
Not sure how tis would affect accessing = the DBs, though.
 

On 2 Dec 2015, at 19:14, Dave Cramer <pg@fastcrypt.com> = wrote:

One thing I noticed is that psql is connecting = via SSL.

Have a look = at the pg logs to see what the error is


On 2 December 2015 at 13:37, = Nuno Zimas <nzimas@gmail.com> wrote:

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(PersistenceUnitProperties.JDBC_DRIV= ER, driver);
          =       properties.put(PersistenceUnitProperties.JDBC_USER= , dbLogin);
          =       properties.put(PersistenceUnitProperties.JDBC_PASS= WORD, dbPwd);
          =       //properties.put(PersistenceUnitProperties.JDBC_PR= OPERTY, dbPwd);

          =       //properties.put(PersistenceUnitProperties.JDBC_UR= L, 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=99= t 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<= /div>



= --Apple-Mail=_730307E2-399A-4D4C-8F6A-79C34AB9E035--