- Mailing list pgsql-jdbc

From Karl Goldstein
Subject
Date
Msg-id 00f001c28424$6e27daf0$6701a8c0@tortilla
Whole thread Raw
Responses Re:
List pgsql-jdbc
Hello,

I am having a problem with queries that return empty result sets.  Whenever
I execute a query that returns no rows, the driver throws a SQLException:

No results were returned by the query.
        at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statem
ent.java:157)
        at
org.postgresql.jdbc1.AbstractJdbc1Statement.executeQuery(AbstractJdbc1Statem
ent.java:141)

I'm assuming this is not the intended behavior, since it's perfectly
reasonable for a query to return an empty result set.

Looking at the source code for AbstractJdbc1Statement and working backwards,
the following seems to be happening:

1) executeQuery() starts looping over the current results until it finds one
that is "really" a result set
2) either AbstractJdbc1ResultSet.getNext() never returns a non-null result,
or AbstractJdbc1ResultSet.reallyResultSet() never returns true (I didn't
track it down that far).
3) looking at AbstractJdbc1ResultSet.getNext(), it simply returns the next
member variable
4) I didn't track down where the AbstractJdbc1ResultSet.next() method is
called, but this statement on line 65 caught my eye:

 if (++current_row >= rows.size())
                        return false;

However, I'm not sure this is related at all since the "next" member
variable gets set by the append(), and I didn't track down where that is
called.

Any advice on this would be appreciated.

Thanks

Karl


pgsql-jdbc by date:

Previous
From: Dave Cramer
Date:
Subject: Re: DatabaseMetaData.getTables() problem
Next
From: Dave Cramer
Date:
Subject: Re: