Problem in getting column names from DatabaseMetadata Object - Mailing list pgsql-jdbc

From stallapp
Subject Problem in getting column names from DatabaseMetadata Object
Date
Msg-id 1446556997253-5872498.post@n5.nabble.com
Whole thread Raw
Responses Re: Problem in getting column names from DatabaseMetadata Object
Re: Problem in getting column names from DatabaseMetadata Object
List pgsql-jdbc
Hi,

I am using the following code to get the column names of my postgres table
but it fails. My database name is "employee" and table name is "employee".

Postgres version : 9.3
jdbc driver version : 9.3

public class DBTest {
    public static void main(String[] args) throws Throwable {
        Connection conn = getDBConnection();
        DatabaseMetaData metaData = conn.getMetaData();
        ResultSet resultSet = metaData.getColumns(null, "employee", "employee",
null);

        if (!resultSet.next())
            System.out.println("No result set Entries!!");

        while (resultSet.next()) {
            System.out.println(resultSet.getString("COLUMN_NAME"));
        }
        conn.close();
    }

    public static Connection getDBConnection() {
        Connection conn = null;
        try {
            Class.forName("org.postgresql.Driver");

            conn =
DriverManager.getConnection("jdbc:postgresql://sampel.db:5432/data_gen",
"postgres",
                    "postgres");
        } catch (Throwable th) {
            th.printStackTrace();
        }
        return conn;
    }

any ideas??

Thanks



--
View this message in context:
http://postgresql.nabble.com/Problem-in-getting-column-names-from-DatabaseMetadata-Object-tp5872498.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


pgsql-jdbc by date:

Previous
From: Chapman Flack
Date:
Subject: more re: possible pljava / pgjdbc / pgjdbc-ng code sharing
Next
From: Thomas Kellerer
Date:
Subject: Re: Problem in getting column names from DatabaseMetadata Object