Re: Create Database using JDBC

From: "Nidhi Srivastava" <nsrivastava(at)quark(dot)com>
To: "Nidhi Srivastava" <nsrivastava(at)quark(dot)com>, "Thomas Dudziak" <tomdzk(at)gmail(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>, "John R Pierce" <pierce(at)hogranch(dot)com>
Subject: Re: Create Database using JDBC
Date: 2005-07-04 04:29:41
Message-ID: 2BC68159E3EC814BA1E81C108DF99A4203A37FDC@EXCH-IND-VS1.india.quark.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Even when I'm not accessing templte1 but any other scratch database
through pgAdmin and try to create a new DB using JDBC I get the same
ERROR: CREATE DATABASE: source database "template1" is being accessed
by other users. Is there a way to check if a DB exists and create it if
it doesn't using JDBC. How can I ensure that pgAdmin is not open on any
of the client machines and connected to the Postgre server on my
machine....becuase if even a single pgAdmin client is open on any of the
client machines it doesn't allow me to create a new DB throwing the
above error.

Thanks & Regards
Nidhi

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Nidhi Srivastava
Sent: Friday, July 01, 2005 4:04 PM
To: Thomas Dudziak; pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Create Database using JDBC

Yes I have the pgAdmin open. Is there any work around to check if more
than one users are connected to the server and resolve this?

Or is there any way I can create a DB at the time of Postgres
installation itself. I'm using postgresql8.0 on windows.

If you can't see the bright side of life, polish the dull side.

-----Original Message-----
From: pgsql-jdbc-owner(at)postgresql(dot)org
[mailto:pgsql-jdbc-owner(at)postgresql(dot)org] On Behalf Of Thomas Dudziak
Sent: Friday, July 01, 2005 3:56 PM
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Create Database using JDBC

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

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jonas Partner 2005-07-04 08:15:12 Write to outputstream in PGStream blocks indefinitely
Previous Message Jesper Thorhauge 2005-07-02 08:00:44 Re: Streaming blob to db