Re: Get a table name - Mailing list pgsql-jdbc

From Oliver Jowett
Subject Re: Get a table name
Date
Msg-id 4B3809D7.9090407@opencloud.com
Whole thread Raw
In response to Get a table name  (Gianvito Pio <pio.gianvito@gmail.com>)
Responses Re: Get a table name
List 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

pgsql-jdbc by date:

Previous
From: Maciek Sakrejda
Date:
Subject: Re: Get a table name
Next
From: Oliver Jowett
Date:
Subject: Re: Get a table name