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 5FC60DB874 for ; Wed, 23 Nov 2005 06:58:07 -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 34918-09 for ; Wed, 23 Nov 2005 10:58:05 +0000 (GMT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by svr1.postgresql.org (Postfix) with ESMTP id D42D8DB74D for ; Wed, 23 Nov 2005 06:58:00 -0400 (AST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=[192.168.0.20]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1EesK0-0001uK-JR; Wed, 23 Nov 2005 23:57:52 +1300 Message-ID: <43844B2F.1010309@opencloud.com> Date: Wed, 23 Nov 2005 23:57:51 +1300 From: Oliver Jowett User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051009) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Rob Kirkbride CC: pgsql-jdbc@postgresql.org Subject: Re: Switching user within connection. References: <43843F94.6070900@rkcomputing.co.uk> In-Reply-To: <43843F94.6070900@rkcomputing.co.uk> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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/162 X-Sequence-Number: 14260 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. -O