X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9AD5ADB828 for ; Wed, 23 Nov 2005 07:09:11 -0400 (AST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 53914-03 for ; Wed, 23 Nov 2005 11:09:13 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from mra01.ch.as12513.net (mra01.ch.as12513.net [82.153.252.23]) by svr1.postgresql.org (Postfix) with ESMTP id C156CDB723 for ; Wed, 23 Nov 2005 07:09:08 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mra01.ch.as12513.net (Postfix) with ESMTP id 4C6AC28C818; Wed, 23 Nov 2005 11:09:11 +0000 (GMT) Received: from mra01.ch.as12513.net ([127.0.0.1]) by localhost (mra01.ch.as12513.net [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 02370-01-25; Wed, 23 Nov 2005 11:09:09 +0000 (GMT) Received: from [10.0.0.151] (unknown [81.5.146.249]) by mra01.ch.as12513.net (Postfix) with ESMTP id A68B528C829; Wed, 23 Nov 2005 11:09:07 +0000 (GMT) Message-ID: <43844DCC.3040705@rkcomputing.co.uk> Date: Wed, 23 Nov 2005 11:09:00 +0000 From: Rob Kirkbride User-Agent: Mozilla Thunderbird 1.0.2 (X11/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Oliver Jowett CC: pgsql-jdbc@postgresql.org Subject: Re: Switching user within connection. References: <43843F94.6070900@rkcomputing.co.uk> <43844B2F.1010309@opencloud.com> In-Reply-To: <43844B2F.1010309@opencloud.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by Eclipse VIRUSshield at eclipse.net.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200511/164 X-Sequence-Number: 14262 Oliver Jowett wrote: > Rob Kirkbride wrote: > >> Is there a standard way (or indeed a special way in Postgres) to >> switch user/password without creating a new connection? >> You can obviously do it within psql with \c but I wondered whether >> there was a way in JDBC? > > > There is no standard JDBC way I know of, short of reconnecting. > > AFAIK there's no way at the protocol level to reauthenticate as a > different user on an existing connection. I believe psql's \c command > actually establishes a new connection. > > If you originally connected as the database superuser you could use > SET SESSION AUTHORIZATION to get a similar effect; see > http://www.postgresql.org/docs/8.1/static/sql-set-session-authorization.html. > > Thanks for your reply. I think I'd guessed that would be the reply. It's probably off topic really now but I wanted to maintain a series of pooled connections but with potentially different users. I got lost reading the JCA documentation which may do something clever but I'm guessing if the underlying JDBC driver doesn't support it then there's not a lot it can do really. Rob