Statement.executeQuery() and no results - Mailing list pgsql-jdbc

From Sailesh Krishnamurthy
Subject Statement.executeQuery() and no results
Date
Msg-id bxyy8yqdkku.fsf@datafix.cs.berkeley.edu
Whole thread Raw
Responses Re: Statement.executeQuery() and no results  (Kris Jurka <books@ejurka.com>)
Re: Statement.executeQuery() and no results  (Oliver Jowett <oliver@opencloud.com>)
Re: Statement.executeQuery() and no results  (Barry Lind <blind@xythos.com>)
List pgsql-jdbc
Folks

When we run a query that produces no results, executeQuery() returns
an exception instead of a ResultSet object for which the first call to
next() returns false. (This is with a driver for pgsql 7.3.2)

Here is some code in AbstractJdbc1Statement.java

    /*
     * A Prepared SQL query is executed and its ResultSet is returned
     *
     * @return a ResultSet that contains the data produced by the
     *         *    query - never null
     * @exception SQLException if a database access error occurs
     */
    public java.sql.ResultSet executeQuery() throws SQLException
    {
      this.execute(false);
      while (result != null && !((AbstractJdbc1ResultSet)result).reallyResultSet())
        result = ((AbstractJdbc1ResultSet)result).getNext();
      if (result == null)
        throw new PSQLException("postgresql.stat.noresult");
      return result;
    }

Is my understanding correct ? Is this working as designed ? I'm not
convinced that this is as per the spec. I would rather see a ResultSet
object returned instead of an exception.

--
Pip-pip
Sailesh
http://www.cs.berkeley.edu/~sailesh


pgsql-jdbc by date:

Previous
From: Kris Jurka
Date:
Subject: Re: RFC: Removal of support for JDBC1 drivers.
Next
From: Kris Jurka
Date:
Subject: Re: Statement.executeQuery() and no results