Skip site navigation (1) Skip section navigation (2)

Bug - DatabaseMetaData.getCatalogs() was [Novice] Can't get list of databases with \list

From: Richard Broersma <richard(dot)broersma(at)gmail(dot)com>
To: Christopher Frank <c(dot)frank(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org, pgsql-jdbc <pgsql-jdbc(at)postgresql(dot)org>
Subject: Bug - DatabaseMetaData.getCatalogs() was [Novice] Can't get list of databases with \list
Date: 2009-11-03 17:36:56
Message-ID: 396486430911030936r725f6163m3384fad30721b36c@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-jdbcpgsql-novice
On Mon, Nov 2, 2009 at 1:05 PM, Christopher Frank <c(dot)frank(at)gmail(dot)com> wrote:

>> > As for JDBC, there may be something that gives equivalent information,
>> > but I
>> > couldn't find it.
>>
>> http://java.sun.com/javase/6/docs/api/java/sql/DatabaseMetaData.html
>>
>> getCatalogs()

> I had tried that but it only returned one database, the database to which I
> was already connected. There should have been 3 others.

I verified that the DatabaseMetaData.getCatalogs() only returns a
ResultSet with the currently connect database rather than all of the
databases in the PostgreSQL cluster.

I see there was a previous discussion on this topic, stating that
Databases and Catalogs are not the same, so only returning the
currently connected database is correct:

http://archives.postgresql.org/pgsql-jdbc/2007-02/msg00112.php

However, calling the DatabaseMetaData.getCatalogTerm() function states
that the PostgreSQL's equivalent to a Catalog is a "database".  For
this reason, it seems reasonable to me that getCatalogs() should
return a listing off all PostgreSQL databases.

If one really only wants the currently connected database,
Connection.getCatalog() will suffice.

-- 
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

Responses

pgsql-novice by date

Next:From: Francisco LeoveyDate: 2009-11-03 17:57:42
Subject: Re: Bug - DatabaseMetaData.getCatalogs() was [Novice] Can't get list of databases with \list
Previous:From: Michael LushDate: 2009-11-03 17:04:49
Subject: Determining database status

pgsql-jdbc by date

Next:From: Francisco LeoveyDate: 2009-11-03 17:57:42
Subject: Re: Bug - DatabaseMetaData.getCatalogs() was [Novice] Can't get list of databases with \list
Previous:From: Carl ShelbourneDate: 2009-11-03 13:15:21
Subject: Help with prepared statment for crosstab

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group