X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 42F189DCD0E for ; Sat, 17 Dec 2005 09:23:50 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 91455-05 for ; Sat, 17 Dec 2005 09:23:53 -0400 (AST) X-Greylist: delayed 00:05:05.186559 by SQLgrey- Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by postgresql.org (Postfix) with ESMTP id D7B7B9DCD1C for ; Sat, 17 Dec 2005 09:23:47 -0400 (AST) Received: from [84.157.62.222] (helo=lunix.schabi.de) by mrelayeu.kundenserver.de (node=mrelayeu7) with ESMTP (Nemesis), id 0ML2Dk-1EnbxP08UO-0005pW; Sat, 17 Dec 2005 14:18:39 +0100 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lunix.schabi.de (Postfix) with ESMTP id 697B764D07; Sat, 17 Dec 2005 14:19:00 +0100 (CET) Message-ID: <43A41044.2010802@logix-tt.com> Date: Sat, 17 Dec 2005 14:19:00 +0100 From: Markus Schaber User-Agent: Mozilla Thunderbird 1.0.7 (X11/20051017) X-Accept-Language: de-DE, de, en-us, en MIME-Version: 1.0 To: Nidhi Srivastava CC: pgsql-jdbc@postgresql.org Subject: Re: Create Database using JDBC References: <2BC68159E3EC814BA1E81C108DF99A4203A37FD9@EXCH-IND-VS1.india.quark.com> In-Reply-To: <2BC68159E3EC814BA1E81C108DF99A4203A37FD9@EXCH-IND-VS1.india.quark.com> X-Enigmail-Version: 0.93.0.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Provags-ID: kundenserver.de abuse@kundenserver.de login:a9554655f07a4e401310f2acfb43f5bf 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: 200512/78 X-Sequence-Number: 14409 Hi, Nidhi, Nidhi Srivastava schrieb: > I wish to create a database if one doesn’t exist using JDBC. I tried > connecting to template1 database and then issuing the “CREATE DATABASE > test” command but I get the following error : > > ERROR: CREATE DATABASE: source database "template1" > > is being accessed by other users > > How do I resolve this? I’m using PostGreSQL8.0 This is a PostgreSQL limitation, in that you cannot use a database as template if anyone else except the one who issued the create database has a connection to it. You can either use "template0" as template (if you did not apply any modifications to template1), or create your own templateblah database which you use as template. Btw, the Debian PostgreSQL packagers seem to add an empty database called "postgresql" to each cluster, and then all tools (e. G. pgadmin) are told to use this database to connect against, so the template database is kept reserved for real templating issues. Maybe this could be adopted upstream. HTH, Markus