From: Michael Fork <mfork00@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: PSQLException: The column name <col> was not found in this ResultSet.
Date: Mon, 8 Nov 2010 05:54:30 -0800 (PST)
Message-ID: <270369.52816.qm@web113412.mail.gq1.yahoo.com> (raw)
postgresql-9.0-801.jdbc3.jar
PostgreSQL 8.3.7 on amd64-portbld-freebsd7.2, compiled by GCC cc (GCC) 4.2.1
20070719 [FreeBSD]
Caused by: org.postgresql.util.PSQLException: The column name mdn was not found
in this ResultSet.
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.findColumn(AbstractJdbc2ResultSet.java:2562)
at
org.postgresql.jdbc2.AbstractJdbc2ResultSet.getString(AbstractJdbc2ResultSet.java:2405)
at
org.apache.commons.dbcp.DelegatingResultSet.getString(DelegatingResultSet.java:225)
I receive the above error message when accessing the JDBC resultset from
multiple threads. It does not occur consistently, but roughly every 20 or 30
runs and almost immediately upon invocation. Looking
at org/postgresql/jdbc2/AbstractJdbc2ResultSet.java it appears there is a race
condition around building columnNameIndexMap
if (columnNameIndexMap == null) { columnNameIndexMap
= new HashMap(fields.length * 2); // The JDBC spec says when you
have duplicate columns names, // the first one should be returned.
So load the map in // reverse order so the first ones will overwrite
later ones. for (int i = fields.length - 1; i >= 0; i--)
{
columnNameIndexMap.put(fields[i].getColumnLabel().toLowerCase(Locale.US), new
Integer(i + 1)); } }
I cannot confirm this, but I would guess that on thread enters, has the NULL map
and creates the new HashMap. The second thread enters, sees the non-NULL
columnNameIndexMap, and gets to the HashMap.get call prior to the first thread
fully populating the map. If this is the problem, would wrapping the IF block
in a synchronized(this) block fix it?
Thanks.
Michael
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: mfork00@yahoo.com
Subject: Re: PSQLException: The column name <col> was not found in this ResultSet.
In-Reply-To: <270369.52816.qm@web113412.mail.gq1.yahoo.com>
References: <270369.52816.qm@web113412.mail.gq1.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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