Re: Create Database using JDBC

From: Csaba Nagy <nagy(at)ecircle-ag(dot)com>
To: Thomas Dudziak <tomdzk(at)gmail(dot)com>
Cc: Postgres JDBC <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Create Database using JDBC
Date: 2005-07-01 10:36:00
Message-ID: 1120214160.3085.87.camel@coppola.muc.ecircle.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

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 <nsrivastava(at)quark(dot)com> 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2005-07-01 12:30:21 Re: Create Database using JDBC
Previous Message Nidhi Srivastava 2005-07-01 10:33:55 Re: Create Database using JDBC