pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Kris Jurka <books@ejurka.com>
Cc: miguel manzano <miguel.miguelmanzano@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: I can't get the database's list
Date: Wed, 09 Jun 2010 14:14:08 +0800
Message-ID: <4C0F3130.4010405@postnewspapers.com.au> (raw)
In-Reply-To: <alpine.BSO.2.00.1006090206001.2333@leary.csoft.net>
References: <1276050127.8267.6.camel@localhost>
	<alpine.BSO.2.00.1006090206001.2333@leary.csoft.net>

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/



view thread (3+ messages)

Message-ID: <4C0F3130.4010405@postnewspapers.com.au>
Permalink:  ../4C0F3130.4010405@postnewspapers.com.au/
Also on:    postgresql.org/message-id/4C0F3130.4010405@postnewspapers.com.au

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: craig@postnewspapers.com.au, books@ejurka.com, miguel.miguelmanzano@gmail.com
  Subject: Re: I can't get the database's list
  In-Reply-To: <4C0F3130.4010405@postnewspapers.com.au>
  References: <1276050127.8267.6.camel@localhost> <alpine.BSO.2.00.1006090206001.2333@leary.csoft.net> <4C0F3130.4010405@postnewspapers.com.au>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox