PSQLException: The column name was not found in this ResultSet.

Поиск
Список
Период
Сортировка
was not found in this ResultSet.was not found in this ResultSet.  (Kris Jurka <books@ejurka.com>)
От Michael Fork
Тема PSQLException: The column name
Дата
Msg-id 270369.52816.qm@web113412.mail.gq1.yahoo.com
обсуждение исходный текст
Ответы Re: PSQLException: The column name
Список pgsql-jdbc
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


В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: Bug with DatabaseMetaData and temporary tables/schemas
Следующее
От: Steven Dahlin
Дата:
Сообщение: psqlexception syntax error at or near "$"