ResultSet next() returning true when no rows

Поиск
Список
Период
Сортировка
От Seth Rubin
Тема ResultSet next() returning true when no rows
Дата
Msg-id CNELLBDHOKALJPHOOBBEKEGHDOAA.srubin@thoughtprocess.com
обсуждение исходный текст
Ответы Re: ResultSet next() returning true when no rows  (Oliver Jowett <oliver@opencloud.com>)
Список pgsql-jdbc
I'm using the latest pg73jdbc3.jar production file (from this past August)
with JDK 1.4.2_01 with Tomcat 4.1.27.  On this code:

line 1547      rs = st.executeQuery(sqlStatement);
line 1548      while (rs.next());
line 1549      {
line 1550        int res_id = rs.getInt(1);

The rs.getInt is blowing up with the following error:

Result set not positioned properly, perhaps you need to call next().
    at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.checkResultSet(AbstractJdbc1Resu
ltSet.java:673)
    at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getString(AbstractJdbc1ResultSet
.java:91)
    at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getFixedString(AbstractJdbc1Resu
ltSet.java:642)
    at
org.postgresql.jdbc1.AbstractJdbc1ResultSet.getInt(AbstractJdbc1ResultSet.ja
va:144)
    at com.thoughtprocess.SchedServer.schedQuery(SchedServer.java:1550)

I run the same SQL statement at the psql prompt, and I get zero rows
returned, so for some reason rs.next is returning true even though there's
no data.

What's more maddening is that I try the same code in a separate standalone
java app, and it doesn't experience the same problem.

So there's something funky in my servlet, but I can't figure out what it is.
I've even tried creating a new connection from scratch right before this
SQL, but no dice.  The only thing I can think of is that another thread is
running the exact same query at almost the same second, but I'd hate to
think it's that vulnerable.

Any insights appreciated...
Also, is there a place where the JDBC3 source is available for perusal?

-- Seth


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

Предыдущее
От: Andreas Prohaska
Дата:
Сообщение: Re: j2sdk1.4.2_01 vs. CLASSPATH problem?
Следующее
От: Oliver Jowett
Дата:
Сообщение: Re: ResultSet next() returning true when no rows