Nidhi Srivastava 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
This is no different for JDBC versus createdb. You can't use a database
as a source for CREATE DATABASE if it has more than one active
connection. I suspect you will find that 'createdb' fails with the same
error..
-O