Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id E752D632520 for ; Wed, 9 Jun 2010 03:17:38 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 26044-02 for ; Wed, 9 Jun 2010 06:17:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from www.postnewspapers.com.au (www.postnewspapers.com.au [202.4.227.11]) by mail.postgresql.org (Postfix) with ESMTP id 8D4AF6321B1 for ; Wed, 9 Jun 2010 03:17:31 -0300 (ADT) Received: from mail.postnewspapers.com.au (202-89-185-120.static.dsl.amnet.net.au [202.89.185.120]) by www.postnewspapers.com.au (Postfix) with ESMTP id E0C3F94E8F; Wed, 9 Jun 2010 14:17:20 +0800 (WST) Received: from [10.0.0.53] (wallace.localnet [10.0.0.53]) by mail.postnewspapers.com.au (Postfix) with ESMTP id D8972AE300; Wed, 9 Jun 2010 14:17:07 +0800 (WST) Message-ID: <4C0F3130.4010405@postnewspapers.com.au> Date: Wed, 09 Jun 2010 14:14:08 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100423 Thunderbird/3.0.4 MIME-Version: 1.0 To: Kris Jurka CC: miguel manzano , pgsql-jdbc@postgresql.org Subject: Re: I can't get the database's list References: <1276050127.8267.6.camel@localhost> In-Reply-To: X-Enigmail-Version: 1.0.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/52 X-Sequence-Number: 20622 On 09/06/10 14:09, Kris Jurka wrote: > > > On Tue, 8 Jun 2010, miguel manzano wrote: > >> I try to obtain the database's list in my instalation but when I use : >> >> System.out.println("Driver : "); >> System.out.println(" " + md.getDatabaseProductName() ); >> System.out.println(" " + md.getDatabaseProductVersion() ); >> ResultSet catalogRs = md.getCatalogs(); >> >> while ( catalogRs.next() ){ >> >> System.out.println("Catalog " + catalogRs.getString(1)); >> ResultSet tableRs = >> md.getTables(catalogRs.getString(1),"%","%",(String []) null); >> } >> } >> I just got only the name of the database at I have conected but the >> another databases didn't figure in the list. > > The JDBC driver avoids returning all the databases on the server because > it cannot access them. It can only access the current database so that > is all it returns from getCatalogs. We made this decision intentionally > to handle the exact situation that your next getTables call reveals. If > we returned other databases in getCatalogs, people would try to use them > in other database metadata calls which would not work. To elaborate: If you want to use queries "across databases" or otherwise use more than one database in a single connection, you probably need to use schema not databases to separate things. PostgreSQL's "schema" are like MySQL's "databases"; they're ways of dividing up naming of objects that live within the same storage space. -- Craig Ringer Tech-related writing: http://soapyfrogs.blogspot.com/