Re: DatabaseMetaData.getCatalogs()

Поиск
Список
Период
Сортировка
От Altaf Malik
Тема Re: DatabaseMetaData.getCatalogs()
Дата
Msg-id 848835.23875.qm@web39103.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на DatabaseMetaData.getCatalogs()  ("Peter Futaro" <peterfutaro@gmail.com>)
Список pgsql-jdbc
JDBC does not allow to collect an information for the database you are not conected to. The method getCatalogs does not return databases, instead it returns the catalogs in current database. To list down the available databases, you need to query the catalog tables. For example, on postgres you can use :
 
select datname from pg_catalog.pg_database where datname not in('template0','template1')
 
This will populate all the databases.
 
--Altaf Malik
EnterpriseDB
www.enterprisedb.com

Peter Futaro <peterfutaro@gmail.com> wrote:
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


Don't get soaked. Take a quick peak at the forecast
with theYahoo! Search weather shortcut.

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: "Peter Futaro"
Дата:
Сообщение: DatabaseMetaData.getCatalogs()
Следующее
От: "Julius Stroffek"
Дата:
Сообщение: JDBC object factory