Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 322839FB5CE for ; Wed, 21 Feb 2007 05:34:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 67148-05 for ; Wed, 21 Feb 2007 05:34:37 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.168]) by postgresql.org (Postfix) with ESMTP id C58159FB804 for ; Wed, 21 Feb 2007 05:34:36 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so866944ugf for ; Wed, 21 Feb 2007 01:34:33 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:mime-version:content-type; b=UZ03K1PPQMSqmQIvtKbTsAvGFdKrb12NdMwct9i7fAt59ApV0NcJgH9IWTpvoynwcJougGZbVOju3Zmh5R1YUYJb5KT9QMx9HNjhKjKJWDfmM+GTMII/Ecc39dWe9LWEbanmPzVa/OonmsfmZf1UAXr9QWDUeryBAwZ8oUqY4ko= Received: by 10.78.200.3 with SMTP id x3mr1349865huf.1172050472770; Wed, 21 Feb 2007 01:34:32 -0800 (PST) Received: by 10.78.169.17 with HTTP; Wed, 21 Feb 2007 01:34:32 -0800 (PST) Message-ID: Date: Wed, 21 Feb 2007 17:34:32 +0800 From: "Peter Futaro" To: pgsql-jdbc@postgresql.org Subject: DatabaseMetaData.getCatalogs() MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_2173_7414088.1172050472750" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200702/112 X-Sequence-Number: 16668 ------=_Part_2173_7414088.1172050472750 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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://<>: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 ------=_Part_2173_7414088.1172050472750 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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
------=_Part_2173_7414088.1172050472750--