Re: PSQLException: The column name <col> was not found in this ResultSet.

From: Lew <noone(at)lewscanon(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: PSQLException: The column name <col> was not found in this ResultSet.
Date: 2010-11-12 02:09:12
Message-ID: ibi7js$71l$1@news.albasani.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

On 11/10/2010 12:27 AM, Samuel Gendler wrote:
> On Tue, Nov 9, 2010 at 4:10 PM, Kris Jurka <books(at)ejurka(dot)com
> <mailto:books(at)ejurka(dot)com>> wrote:
>
>
>
> On Mon, 8 Nov 2010, Michael Fork wrote:
>
> Caused by: org.postgresql.util.PSQLException: The column name
> mdn was not found
> in this ResultSet.
>
> 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
>
> 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?

IT is possible without proper synchronization for thread A to instantiate and
fully population a shared Map reference, and for thread B subsequently to see
a 'null', empty or partially populated view from that reference.

> That looks like the correct diagnosis and fix to me.
>
>
> That would only be a valid fix if ResultSet is intended to be inherently
> threadsafe. I wouldn't think that is the case. There is no mention of
> thread safety at all in the javadocs, which I would always take to imply
> that there is no implicit thread safety. Code which utilizes a
> ResultSet should do so in a thread safe manner, rather than attempting
> to make the resultset implementation thread-safe - unless my assumptions
> about the intent of the interface designers is incorrect.

It is meaningless to talk about thread safety with respect to interfaces.

--
Lew

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Maciek Sakrejda 2010-11-12 02:58:24 Re: PSQLException: The column name <col> was not found in this ResultSet.
Previous Message Michael Fork 2010-11-10 17:49:40 Re: PSQLException: The column name <col> was not found in this ResultSet.