Re: Use Driver to Create database?

From: "Heikki Linnakangas" <heikki(at)enterprisedb(dot)com>
To: "Roland Walter" <roland(dot)walter(dot)rwa(at)gmx(dot)net>
Cc: "Charlie Kelly" <Charlie(at)CharlieKelly(dot)com>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Use Driver to Create database?
Date: 2006-11-19 22:04:10
Message-ID: 4560D4DA.7090708@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Roland Walter wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Charlie Kelly wrote:
>> Is it possible to use the driver to create a new database (inside a java
>> program),
>> or is it necessary to first create the database using the createdb utility?
>>
>> If it is possible to use the driver, what is the correct syntax?
>>
>
> There is a SQL-command for that, look here:
>
>
> http://www.postgresql.org/docs/8.1/interactive/sql-createdatabase.html
>
> First connect to the postgres or template1 schema of the cluster, that
> you created with initdb. Execute the "CREATE DATABASE". Reconnect to the
> database you created.

You don't want to connect to template1, though, if the program is going
to be used concurrently by more than one use. Template1 is used as
template (hence the name) to make the new database, and it will throw an
error if there's any other users connected to it beside the one issuing
the CREATE DATABASE command.

--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message John R Pierce 2006-11-20 05:07:44 Re: Use Driver to Create database?
Previous Message Roland Walter 2006-11-19 21:46:37 Re: Use Driver to Create database?