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