X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4527F52806 for ; Fri, 1 Jul 2005 07:36:09 -0300 (ADT) 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 62508-04 for ; Fri, 1 Jul 2005 10:36:03 +0000 (GMT) Received: from mail.ecircle.de (mail.ecircle.de [195.140.186.200]) by svr1.postgresql.org (Postfix) with ESMTP id A5F2F5293E for ; Fri, 1 Jul 2005 07:36:01 -0300 (ADT) Received: from [192.168.1.110] (unknown [192.168.1.110]) by mail.ecircle.de (READY) with ESMTP id D427F11DD05; Fri, 1 Jul 2005 12:36:00 +0200 (CEST) Subject: Re: Create Database using JDBC From: Csaba Nagy To: Thomas Dudziak Cc: Postgres JDBC In-Reply-To: <224f3234050701032612fabe04@mail.gmail.com> References: <2BC68159E3EC814BA1E81C108DF99A4203A37FD9@EXCH-IND-VS1.india.quark.com> <224f3234050701032612fabe04@mail.gmail.com> Content-Type: text/plain Message-Id: <1120214160.3085.87.camel@coppola.muc.ecircle.de> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Fri, 01 Jul 2005 12:36:00 +0200 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.017 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/4 X-Sequence-Number: 13152 Hi all, I'm not too knowledgeable about this matter, but wouldn't it work to connect to another data base, not template1 ? And make a policy not to connect to template1. I guess it doesn't matter which data base are you connected to (except that it must exist) when you create a new one. So just create a "standard" data base which always exist, and connect to that one. Cheers, Csaba. On Fri, 2005-07-01 at 12:26, Thomas Dudziak wrote: > On 7/1/05, Nidhi Srivastava wrote: > > > 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 should work (we're doing it exactly the same way). But there can > only be one user connected at a time to the template database, it > seems, at least when using the CREATE DATABASE command. Do you have > the one of the PostgreSQL tools open, eg. pgAdmin ? > > Tom > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster