vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi all 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 Thanks & Regards Nidhi |
| |||
| On 7/1/05, Nidhi Srivastava <nsrivastava@quark.com> 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 > > How do I resolve this? I'm using PostGreSQL8.0 This should work (we're doing it exactly the same way). But there can only be one user connected at a time to the template database, it seems, at least when using the CREATE DATABASE command. Do you have the one of the PostgreSQL tools open, eg. pgAdmin ? Tom ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster |
| |||
| 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 ---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives? http://archives.postgresql.org |
| |||
| Hi all, I'm not too knowledgeable about this matter, but wouldn't it work to connect to another data base, not template1 ? And make a policy not to connect to template1. I guess it doesn't matter which data base are you connected to (except that it must exist) when you create a new one. So just create a "standard" data base which always exist, and connect to that one. Cheers, Csaba. On Fri, 2005-07-01 at 12:26, Thomas Dudziak wrote: > On 7/1/05, Nidhi Srivastava <nsrivastava@quark.com> 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 > > > > How do I resolve this? I'm using PostGreSQL8.0 > > This should work (we're doing it exactly the same way). But there can > only be one user connected at a time to the template database, it > seems, at least when using the CREATE DATABASE command. Do you have > the one of the PostgreSQL tools open, eg. pgAdmin ? > > Tom > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster ---------------------------(end of broadcast)--------------------------- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| |||
| Is it possible you have an existing open transaction on template1 ? Have a look at the postgresql logs. Dave On 1-Jul-05, at 4:30 AM, Nidhi Srivastava wrote: > Hi all > > > > 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 > > > > Thanks & Regards > > Nidhi > > Dave Cramer davec@postgresintl.com www.postgresintl.com ICQ #14675561 jabber davecramer@jabber.org ph (519 939 0336 ) |
| |||
| 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 ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend |
| |||
| On Sat, Dec 17, 2005 at 02:19:00PM +0100, Markus Schaber wrote: > 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. PostgreSQL adds that database automatically on initdb starting with version 8.1. -- Jim C. Nasby, Sr. Engineering Consultant jnasby@pervasive.com Pervasive Software http://pervasive.com work: 512-231-6117 vcard: http://jim.nasby.net/pervasive.vcf cell: 512-569-9461 ---------------------------(end of broadcast)--------------------------- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to majordomo@postgresql.org so that your message can get through to the mailing list cleanly |
| ||||
| Hi, Jim, Jim C. Nasby schrieb: > PostgreSQL adds that database automatically on initdb starting with > version 8.1. Oh, great, then this is not debian specific. :-) Markus ---------------------------(end of broadcast)--------------------------- TIP 5: don't forget to increase your free space map settings |