Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 33DD3632B18 for ; Sun, 27 Dec 2009 21:29:11 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40477-09 for ; Mon, 28 Dec 2009 01:29:03 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by mail.postgresql.org (Postfix) with ESMTP id DAEF16328D6 for ; Sun, 27 Dec 2009 21:29:03 -0400 (AST) Received: from 122-57-40-95.jetstream.xtra.co.nz ([122.57.40.95] helo=[192.168.1.168]) by tremor.opencloud.co.nz with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1NP4Pp-00016d-35; Mon, 28 Dec 2009 14:28:57 +1300 Message-ID: <4B3809D7.9090407@opencloud.com> Date: Mon, 28 Dec 2009 14:28:55 +1300 From: Oliver Jowett User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Gianvito Pio CC: pgsql-jdbc@postgresql.org Subject: Re: Get a table name References: <4B3737DA.4070408@gmail.com> In-Reply-To: <4B3737DA.4070408@gmail.com> Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200912/101 X-Sequence-Number: 20182 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