Skip site navigation (1) Skip section navigation (2)

Re: Get a table name

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: (view raw, whole thread or download thread mbox)
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.


In response to


pgsql-jdbc by date

Next:From: Oliver JowettDate: 2009-12-28 01:31:36
Subject: Re: Get a table name
Previous:From: Maciek SakrejdaDate: 2009-12-27 22:12:30
Subject: Re: Get a table name

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group