From: | Oliver Jowett <oliver(at)opencloud(dot)com> |
---|---|
To: | Gianvito Pio <pio(dot)gianvito(at)gmail(dot)com> |
Cc: | pgsql-jdbc(at)postgresql(dot)org |
Subject: | Re: Get a table name |
Date: | 2009-12-28 01:28:55 |
Message-ID: | 4B3809D7.9090407@opencloud.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-jdbc |
Gianvito Pio wrote:
> Hi all,
> I'm trying to get the table name of a column in this way:
>
> ResultSet rs;
> try
> {
> rs = ps.executeQuery();
> ResultSetMetaData rsmd = rs.getMetaData();
> System.out.println(rsmd.getTableName(..));
>
> but the getTableName( ..) method gives me an empty string. Isn't there a
> way to know the table name of a specific field I'm obtaining? Thanks
You can use PGResultSetMetaData.getBaseTableName() if you want to know
the name of the underlying table that provided the data for a column
(where known).
We concluded a while back that getTableName() is meant to return the
aliased table name in the query, not the underlying table name. It's not
easy for the driver to find the aliased name, so it always returns an
empty string, as you found.
-O
From | Date | Subject | |
---|---|---|---|
Next Message | Oliver Jowett | 2009-12-28 01:31:36 | Re: Get a table name |
Previous Message | Maciek Sakrejda | 2009-12-27 22:12:30 | Re: Get a table name |