pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Futaro <peterfutaro@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: DatabaseMetaData.getCatalogs()
Date: Wed, 21 Feb 2007 17:34:32 +0800
Message-ID: <ef32f7760702210134n18560449l9a6ef125ece83d33@mail.gmail.com> (raw)

Dear all,

I have a remote machine, which is ushing Postgres v.7.4.11.
This machine has 2 database :
Database A & Database B

I have a task to list out the available database inside that machine in a
combo box. I have tried to using :

public String getDBList()
    {
        String s = "";

        try
        {
            Class.forName(sDriver);
            connection_this = DriverManager.getConnection(sURL, sUser,
sPassword);
            dbMetaData_this = connection_this.getMetaData();
            resultSet_this = dbMetaData_this.getCatalogs();

            while(resultSet_this.next())
            {
                if(!resultSet_this.isFirst())
                    s += ",";

                s += resultSet_this.getString(1);
            }

            return s;
        }

        catch(SQLException e)
        {
            return "error";
        }
    }

This will only return the database, that I state inside the URL
(e.g. String sURL = "jdbc:postgresql://<<ip>>:5432/databaseA"  ---> will
return "databaseA" only).

I try to connect without stating any database inside the URL, also cannot.
Can you guys please help me ?

Thank you.

Peter Futaro

view thread (12+ messages)  latest in thread

Message-ID: <ef32f7760702210134n18560449l9a6ef125ece83d33@mail.gmail.com>
Permalink:  ../ef32f7760702210134n18560449l9a6ef125ece83d33@mail.gmail.com/
Also on:    postgresql.org/message-id/ef32f7760702210134n18560449l9a6ef125ece83d33@mail.gmail.com

 · 

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: peterfutaro@gmail.com
  Subject: Re: DatabaseMetaData.getCatalogs()
  In-Reply-To: <ef32f7760702210134n18560449l9a6ef125ece83d33@mail.gmail.com>
  References: <ef32f7760702210134n18560449l9a6ef125ece83d33@mail.gmail.com>

* 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