From: Markus Schaber <schabi@logix-tt.com>
To: Nidhi Srivastava <nsrivastava@quark.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: Create Database using JDBC
Date: Sat, 17 Dec 2005 14:19:00 +0100
Message-ID: <43A41044.2010802@logix-tt.com> (raw)
In-Reply-To: <2BC68159E3EC814BA1E81C108DF99A4203A37FD9@EXCH-IND-VS1.india.quark.com>
References: <2BC68159E3EC814BA1E81C108DF99A4203A37FD9@EXCH-IND-VS1.india.quark.com>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: schabi@logix-tt.com, nsrivastava@quark.com
Subject: Re: Create Database using JDBC
In-Reply-To: <43A41044.2010802@logix-tt.com>
References: <2BC68159E3EC814BA1E81C108DF99A4203A37FD9@EXCH-IND-VS1.india.quark.com> <43A41044.2010802@logix-tt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox