From: | Markus Schaber <schabi(at)logix-tt(dot)com> |
---|---|
To: | Nidhi Srivastava <nsrivastava(at)quark(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Create Database using JDBC |
Date: | 2005-12-17 13:19:00 |
Message-ID: | 43A41044.2010802@logix-tt.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
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
From | Date | Subject | |
---|---|---|---|
Next Message | Markus Schaber | 2005-12-17 13:21:32 | Re: Create Database using JDBC |
Previous Message | Simon Moses | 2005-12-17 05:35:06 | Re: setting & using connection pool in beans for tomcat. |