Re: Create Database using JDBC

From: Oliver Jowett <oliver(at)opencloud(dot)com>
To: Nidhi Srivastava <nsrivastava(at)quark(dot)com>
Cc: Thomas Dudziak <tomdzk(at)gmail(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Create Database using JDBC
Date: 2005-07-05 00:03:30
Message-ID: 42C9CE52.7080908@opencloud.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Nidhi Srivastava wrote:
> Problem is if any client application is connected to another database on
> my server anywhere, I shall not able to create my database using
> template1. How can I determine which other clients are connected to my
> server?

It's not "another database", it is specifically the database that you
are using as the template for CREATE DATABASE that must be idle. See the
CREATE DATABASE docs for details.

Usually template1 is not used for anything else so there's no problem. I
suspect that pgAdmin is connecting to template1 *as well* as to the
database you request -- so just the act of running it means that noone
else can CREATE DATABASE from template1.

Whatever database you end up using as a template, you will need to
ensure that there's noone else connected to it. If having random users
connect to the template DB is a problem, then consider using pg_hba.conf
to enforce this -- i.e. don't let people connect to template1 in the
first place unless they are a particular user who is allowed to CREATE
DATABASE..

This is not JDBC-specific though. I suggest you take the discussion to
pgsql-general where there's a wider audience and you may get more help.

-O

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message 時期 精霊 2005-07-05 10:23:30 Re: Streaming blob to db
Previous Message Dave Cramer 2005-07-04 19:02:35 Re: Create Database using JDBC