pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ResultsetMetaData.getColumnName bug?
2+ messages / 2 participants
[nested] [flat]

* ResultsetMetaData.getColumnName bug?
@ 2007-12-08 14:36 Roy Smith <roy.smith@primetext.com>
  2007-12-08 16:05 ` Re: ResultsetMetaData.getColumnName bug? Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Roy Smith @ 2007-12-08 14:36 UTC (permalink / raw)
  To: pgsql-jdbc

It looks like getColumnName() is incorrectly returning the column label.
They are normally the same, but I have a query "select add as Address" and
resultsetmetadata.getColumnName(1) is retuning "Address" instead of "add".

In the source code of AbstractJdbc2ResultsetMetadata I see this ...

   public String getColumnName(int column) throws SQLException
    {
        return getColumnLabel(column);
    }



best
Roy

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: ResultsetMetaData.getColumnName bug?
  2007-12-08 14:36 ResultsetMetaData.getColumnName bug? Roy Smith <roy.smith@primetext.com>
@ 2007-12-08 16:05 ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Kris Jurka @ 2007-12-08 16:05 UTC (permalink / raw)
  To: Roy Smith <roy.smith@primetext.com>; +Cc: pgsql-jdbc



On Sat, 8 Dec 2007, Roy Smith wrote:

> It looks like getColumnName() is incorrectly returning the column label.
> They are normally the same, but I have a query "select add as Address" and
> resultsetmetadata.getColumnName(1) is retuning "Address" instead of "add".
>

This has been discussed before (see archives), but the simplest 
explanation is that rs.getXXX(rsmd.getColumnName(1)) should work and 
won't if we return the base column name.  To get the result you want use 
((PGResultSetMetaData)rsmd).getBaseColumnName().

Kris Jurka



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2007-12-08 16:05 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-12-08 14:36 ResultsetMetaData.getColumnName bug? Roy Smith <roy.smith@primetext.com>
2007-12-08 16:05 ` Kris Jurka <books@ejurka.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox