| From: | John DeSoi <desoi(at)pgedit(dot)com> |
|---|---|
| To: | Damian C <jamianb(at)gmail(dot)com> |
| Cc: | pgsql-novice(at)postgresql(dot)org |
| Subject: | Re: Simple DB presence verifier. |
| Date: | 2007-03-05 13:25:08 |
| Message-ID: | 4027C48C-EBF5-456C-A3C2-5A3138A34351@pgedit.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-novice |
If PostgreSQL is not running you won't be able to connect to any
database. When you do successfully connect, you have to specify a
database. So if your connection succeeds, you have already verified
the existence of the database. If the database was "missing" you
would get a "database does not exist error".
If Hibernate connects for you and you don't have any commands to
verify the connection, a simple "SELECT 1" should work. If you are
connected and need to verify the existence of a database other than
the one you are connected to then something like:
select count(*) from pg_database where datname = 'postgres';
John
On Mar 4, 2007, at 4:40 PM, Damian C wrote:
> What we are looking for is a simple, low overhead, "quick succeed,
> catchable fail", way to check if the database is available.
>
> Can anyone suggest an improved technique to check for database
> presence??
John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Darkangel Simpson | 2007-03-05 14:36:17 | fsearch2 |
| Previous Message | Damian C | 2007-03-04 21:40:25 | Simple DB presence verifier. |