Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 433F61337BD0 for ; Thu, 31 Mar 2011 04:59:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 05694-09 for ; Thu, 31 Mar 2011 07:58:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smadev.internal.net (host3.dynacom.ondsl.gr [62.103.35.211]) by mail.postgresql.org (Postfix) with ESMTP id 558EC1337BD8 for ; Thu, 31 Mar 2011 04:58:58 -0300 (ADT) Received: from smadev.internal.net (localhost.internal.net [127.0.0.1]) by smadev.internal.net (8.14.2/8.14.2) with ESMTP id p2V7wv3K067547 for ; Thu, 31 Mar 2011 10:58:57 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) Received: from localhost (localhost [[UNIX: localhost]]) by smadev.internal.net (8.14.2/8.14.2/Submit) id p2V7wv6t067546 for pgsql-jdbc@postgresql.org; Thu, 31 Mar 2011 10:58:57 +0300 (EEST) (envelope-from achill@matrix.gatewaynet.com) From: Achilleas Mantzios Organization: Dynacom Tankers Mgmt To: pgsql-jdbc@postgresql.org Subject: Re: JDBC gripe list Date: Thu, 31 Mar 2011 09:58:56 +0200 User-Agent: KMail/1.9.7 References: <201103311029.10460.achill@matrix.gatewaynet.com> In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <201103311058.57025.achill@matrix.gatewaynet.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.451 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_BRBL_LASTEXT=1.449 X-Spam-Level: X-Archive-Number: 201103/145 X-Sequence-Number: 21700 =CE=A3=CF=84=CE=B9=CF=82 Thursday 31 March 2011 10:42:50 =CE=BF/=CE=B7 Thom= as Kellerer =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=B5: > Achilleas Mantzios, 31.03.2011 09:29: > > Currently most people define an app server (usually super) user to acce= ss the database, > > and the connections in the pool are created with this db user connectin= g to the db. > > Numerous times I encountered situations where I would like to link entr= ies > > from the web/app server access log (where app server usernames are logg= ed) > > with entries from the postgresql log, where only the app server db user= is logged. > > In order to to this corelation, or even worse to *prove* that app serve= r user (lets call him Uapp) > > caused or did not cause this erroneous/malicious DB statement, one has = to grep for SQL stmts > > through the source, then idntify some apps as candidated for having bee= n run, > > and then try to find from the web/app server access logs who those peop= le are. > > This does not work nice and is not accurate. > > > If you are on 9.0 and have control over the connection initialization in = the pool, then using 9.0's "application_name" might be a solution to this. >=20 > If you can configure the pool to run >=20 > SET application_name =3D 'app_user_name' >=20 > when a connection is taken out of the pool, then this name can be part of= the log message in the PostgreSQL logfile. >=20 Yes, sure, thanx for sharing this. One could indeed do this by hacking/subc= lassing the relevant pool classes in the app server. But that would still be a work around. I dont know why SET application =3D'' is reflected in the log files, but SE= T ROLE is not. Is it intentional ? Anyways this question should be targeted to the backend= guys rather than here. > I don't think the standard pools that are available in Java (C3P0 or DBCP= ) can use a "dynamic" statement like this (as it requires injecting a value= that changes during time), but maybe there is a way... >=20 > Regards > Thomas >=20 >=20 =2D-=20 Achilleas Mantzios