Re: Simple DB presence verifier. - Mailing list pgsql-novice

From John DeSoi
Subject Re: Simple DB presence verifier.
Date
Msg-id 4027C48C-EBF5-456C-A3C2-5A3138A34351@pgedit.com
Whole thread Raw
In response to Simple DB presence verifier.  ("Damian C" <jamianb@gmail.com>)
List 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


pgsql-novice by date:

Previous
From: "Damian C"
Date:
Subject: Simple DB presence verifier.
Next
From: "Darkangel Simpson"
Date:
Subject: fsearch2