Re: Listing Database

Lists: pgsql-jdbc
From: Steven Bell <sfbell(at)keasdesign(dot)net>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Listing Database
Date: 2004-07-02 18:21:41
Message-ID: 40E5A7B5.6060707@keasdesign.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Hello,

I am starting out with the PostgreSQL JDBC and I was wondering how to
get a list of the databases. I know from the psql command line, \l will
do it. But how about within a Java app?

Thanks,
Steve.


From: "Chris Smith" <cdsmith(at)twu(dot)net>
To: "Steven Bell" <sfbell(at)keasdesign(dot)net>, <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Listing Database
Date: 2004-07-02 18:33:27
Message-ID: 01da01c46063$11c9e790$6f00000a@KYA
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

Steven Bell wrote:
> I am starting out with the PostgreSQL JDBC and I was wondering how to
> get a list of the databases. I know from the psql command line, \l
> will do it. But how about within a Java app?

Just a guess, but you might connect to a database that you know is there
(template1?) and call DatabaseMetaData.getCatalogs(). Does that work?

--
www.designacourse.com
The Easiest Way to Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation


From: Franco Bruno Borghesi <franco(at)akyasociados(dot)com(dot)ar>
To: Steven Bell <sfbell(at)keasdesign(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Listing Database
Date: 2004-07-02 18:50:17
Message-ID: 1088794217.2386.1.camel@taz.oficina
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-jdbc

what if you just execute the query "select datname from pg_database" in
a Statement and iterate the ResultSet?

On Fri, 2004-07-02 at 15:21, Steven Bell wrote:

> Hello,
>
> I am starting out with the PostgreSQL JDBC and I was wondering how to
> get a list of the databases. I know from the psql command line, \l will
> do it. But how about within a Java app?
>
> Thanks,
> Steve.
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>