Re: FW: Question about the postgres resultset implementation

From: Kris Jurka <books(at)ejurka(dot)com>
To: "Tornroth, Phill" <ptornroth(at)intellidot(dot)net>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: FW: Question about the postgres resultset implementation
Date: 2004-10-13 21:03:16
Message-ID: Pine.BSO.4.56.0410131600250.2777@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On Wed, 13 Oct 2004, Kris Jurka wrote:

> I believe Peter's suggestion was to use a hashmap to cache the
> string->index mapping so that findColumn would only need to do the
> equalsIgnoreCase on the first call of that string, meaning once per column
> instead of for every call.
>

I've committed a fix to cvs following this suggestion. The new findColumn
method looks like this:

Kris Jurka

public int findColumn(String columnName) throws SQLException
{
Integer index = (Integer)columnNameIndexMap.get(columnName);
if (index != null) {
return index.intValue();
}

final int flen = fields.length;
for (int i = 0 ; i < flen; ++i) {
if (fields[i].getColumnLabel().equalsIgnoreCase(columnName)) {
index = new Integer(i+1);
columnNameIndexMap.put(columnName, index);
return index.intValue();
}
}

throw new PSQLException (GT.tr("The column name '{0}' was not found in this ResultSet.", columnName));
}

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Oliver Jowett 2004-10-13 21:06:48 Re: FW: Question about the postgres resultset implementation
Previous Message Oliver Jowett 2004-10-13 20:48:56 Re: odd insert problem, textarea \n replaced with <br> gives