Why?? executeQuery() & exception: "No results were returned by the query." - Mailing list pgsql-jdbc

From Panu Outinen
Subject Why?? executeQuery() & exception: "No results were returned by the query."
Date
Msg-id 5.0.2.1.0.20010508164432.02d1dca0@vertex.fi
Whole thread Raw
Responses Re: Why?? executeQuery() & exception: "No results were returned by the query."  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-jdbc
Hi there !

Can anyone explain why does executeQuery() throws an exception
"No results were returned by the query."
when result set is empty ???????

In my opinion (and also e.g. Oracle's JDBC driver's opinion) that this is
just normal and user can check the number of rows (=0) that none was
returned. It's totally different to make a query where something is wrong
in the query itself e.g. non-existant column is used or perhaps in the
database connection!

This is "pain in the *ss" to test against in one's code for every different
JDBC driver's DIFFERENT return string there available and it's impossible
to do code that works for even unknown drivers. And Postgresql has even
language dependant versions of this !!!

Since Postgresql source code is so nicely publicly available (thank you all
there!) and thus improvements are easily given by anyone I just wonder if
this could be improved, please !!!

   - Panu

PS. I know for sure that at least SQL Server throws the following when used
through JDBC-ODBC bridge: "No ResultSet was produced".


----------------------------------------------------------------------

org\postgresql\jdbc2\Statement.java:

...
    /**
     * Execute a SQL statement that retruns a single ResultSet
     *
     * @param sql typically a static SQL SELECT statement
     * @return a ResulSet that contains the data produced by the query
     * @exception SQLException if a database access error occurs
     */
    public java.sql.ResultSet executeQuery(String sql) throws SQLException
    {
        this.execute(sql);
        while (result != null &&
!((org.postgresql.ResultSet)result).reallyResultSet())
        result = ((org.postgresql.ResultSet)result).getNext();
        if (result == null)
        throw new PSQLException("postgresql.stat.noresult");
        return result;
    }
...

----------------------------------------------------------------------


pgsql-jdbc by date:

Previous
From: Tony Grant
Date:
Subject: Re: AGAIN: still no answer ... peter, or anybody knowledgeable, please ....
Next
From: Palle Girgensohn
Date:
Subject: Re: [INTERFACES] Trouble with JDBC2 ResultSet.getDate()