Thread: "No results were returned by the query" exceptions

"No results were returned by the query" exceptions

From
Tim Lewis
Date:
Hi people,

Am I correct in assuming that the new driver now throws an exception
when a "No results were returned by the query" occurs for a prepared sql
statement.  I have recently upgraded the driver from 7.1 to 7.2 and my
application now throws this exception when a query returns no rows in
the result set.

Could someone clarify this with me.

Thanks,

Tim Lewis


Re: "No results were returned by the query" exceptions

From
Thomas O'Dowd
Date:
Hi Tim,

I'm not using the latest driver right now, but I can't see why it
should do this because a) the driver doesn't currently support
error codes so without parsing the error message you can't tell
if its a real error or not. b) isn't this what ResultSet.next() is
for? c) in my understanding of the java api, that would be unexpected
behaviour. I maybe wrong but I'd love to hear the reasons why.

Tom.

On Wed, Mar 20, 2002 at 11:00:52AM +1100, Tim Lewis wrote:
> Hi people,
>
> Am I correct in assuming that the new driver now throws an exception
> when a "No results were returned by the query" occurs for a prepared sql
> statement.  I have recently upgraded the driver from 7.1 to 7.2 and my
> application now throws this exception when a query returns no rows in
> the result set.
>
> Could someone clarify this with me.
>
> Thanks,
>
> Tim Lewis
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Thomas O'Dowd. - Nooping - http://nooper.com
tom@nooper.com - Testing - http://nooper.co.jp/labs

Re: "No results were returned by the query" exceptions

From
Peter V Cooper
Date:
I think next() should return false on the first call instead of an exception.
That way all the code I am used to running will work.

Maybe I am missing something in this post but from the java.sql in the
java 2 Platform:
next
public boolean next()
             throws
SQLException
Moves the cursor down one row from its current position. A ResultSet cursor is initially positioned before the first row; the first call to the method next makes the first row the current row; the second call makes the second row the current row, and so on.
If an input stream is open for the current row, a call to the method next will implicitly close it. A ResultSet object's warning chain is cleared when a new row is read.
Returns:
true if the new current row is valid; false if there are no more rows
Throws:
SQLException - if a database access error occurs

Note: false if there are no more rows. I would think this would apply to an empty
result set and return false on the first call - not throw an exception. I think,
if I am not mistaken, this what other DB's do. Is the original poster correct about
an exception? Maybe there was a real database access error as well.

At 09:47 AM 3/20/2002 +0900, Thomas O'Dowd wrote:
Hi Tim,

I'm not using the latest driver right now, but I can't see why it
should do this because a) the driver doesn't currently support
error codes so without parsing the error message you can't tell
if its a real error or not. b) isn't this what ResultSet.next() is
for? c) in my understanding of the java api, that would be unexpected
behaviour. I maybe wrong but I'd love to hear the reasons why.

Tom.

On Wed, Mar 20, 2002 at 11:00:52AM +1100, Tim Lewis wrote:
> Hi people,
>
> Am I correct in assuming that the new driver now throws an exception
> when a "No results were returned by the query" occurs for a prepared sql
> statement.  I have recently upgraded the driver from 7.1 to 7.2 and my
> application now throws this exception when a query returns no rows in
> the result set.
>
> Could someone clarify this with me.
>
> Thanks,
>
> Tim Lewis
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org

--
Thomas O'Dowd. - Nooping - http://nooper.com
tom@nooper.com - Testing - http://nooper.co.jp/labs

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html

Re: "No results were returned by the query" exceptions

From
"Dave Cramer"
Date:
Yes,

I can confirm that it does indeed throw an exception. I will have a look
at this shortly.

Thanks,

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
> Sent: Tuesday, March 19, 2002 7:01 PM
> To: pgsql-jdbc@postgresql.org
> Subject: [JDBC] "No results were returned by the query" exceptions
>
>
> Hi people,
>
> Am I correct in assuming that the new driver now throws an
> exception when a "No results were returned by the query"
> occurs for a prepared sql statement.  I have recently
> upgraded the driver from 7.1 to 7.2 and my application now
> throws this exception when a query returns no rows in the result set.
>
> Could someone clarify this with me.
>
> Thanks,
>
> Tim Lewis
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
http://archives.postgresql.org



Re: "No results were returned by the query" exceptions - redux

From
"Dave Cramer"
Date:
Actually it depends on the query

"select * from y" where y has no rows returns a result set with no rows

";" which is an empty query throws an exception

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Dave Cramer
> Sent: Tuesday, March 19, 2002 9:24 PM
> To: 'Tim Lewis'; pgsql-jdbc@postgresql.org
> Subject: Re: [JDBC] "No results were returned by the query" exceptions
>
>
> Yes,
>
> I can confirm that it does indeed throw an exception. I will
> have a look at this shortly.
>
> Thanks,
>
> Dave
>
> > -----Original Message-----
> > From: pgsql-jdbc-owner@postgresql.org
> > [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
> > Sent: Tuesday, March 19, 2002 7:01 PM
> > To: pgsql-jdbc@postgresql.org
> > Subject: [JDBC] "No results were returned by the query" exceptions
> >
> >
> > Hi people,
> >
> > Am I correct in assuming that the new driver now throws an
> > exception when a "No results were returned by the query"
> > occurs for a prepared sql statement.  I have recently
> > upgraded the driver from 7.1 to 7.2 and my application now
> > throws this exception when a query returns no rows in the
> result set.
> >
> > Could someone clarify this with me.
> >
> > Thanks,
> >
> > Tim Lewis
> >
> >
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 6: Have you searched our list archives?
> >
> http://archives.postgresql.org
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
http://archives.postgresql.org



Re: "No results were returned by the query" exceptions

From
Tim Lewis
Date:
For what its worth Dave,  there are two places in my code where it the exception occurs and with both of them there is a prior statement to lock the table in share row exclusive mode. ie:

Statement st = db.createStatement();
st.executeUpdate("lock table tablex in share row exclusive mode");

String statment = "select col1 from tablex where col2 = ?";
PreparedStatement ps = db.prepareStatement(statement);
ps.setString(1, col2text);
ResultSet rs = ps.executeQuery();     // <- Exception thrown here
 

It may be coincidental but I thought it would be remiss of me to leave it out.

Tim.

Dave Cramer wrote:

Yes,

I can confirm that it does indeed throw an exception. I will have a look
at this shortly.

Thanks,

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
> Sent: Tuesday, March 19, 2002 7:01 PM
> To: pgsql-jdbc@postgresql.org
> Subject: [JDBC] "No results were returned by the query" exceptions
>
>
> Hi people,
>
> Am I correct in assuming that the new driver now throws an
> exception when a "No results were returned by the query"
> occurs for a prepared sql statement.  I have recently
> upgraded the driver from 7.1 to 7.2 and my application now
> throws this exception when a query returns no rows in the result set.
>
> Could someone clarify this with me.
>
> Thanks,
>
> Tim Lewis
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
http://archives.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

-- 
Tim Lewis
Senior Software Engineer
Hitwise
Level 7/580 St Kilda Road
Melbourne, Victoria 3004
Phone : +61-3-8530-2400
Direct: +61-3-8530-2402
Fax   : +61-3-9529-8907
Mobile: 0414 726 899
Email : tim.lewis@hitwise.com
 

Re: "No results were returned by the query" exceptions

From
"Dave Cramer"
Date:
Tim,
 
The latest driver which is experimental doesn't throw an exception and I copied your lock as well
 
can you try it, it is the dev driver on the jdbc site.
 
let me know what else you find, if anything
 
Dave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
Sent: Tuesday, March 19, 2002 9:45 PM
To: Dave@micro-automation.net
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] "No results were returned by the query" exceptions

For what its worth Dave,  there are two places in my code where it the exception occurs and with both of them there is a prior statement to lock the table in share row exclusive mode. ie:

Statement st = db.createStatement();
st.executeUpdate("lock table tablex in share row exclusive mode");

String statment = "select col1 from tablex where col2 = ?";
PreparedStatement ps = db.prepareStatement(statement);
ps.setString(1, col2text);
ResultSet rs = ps.executeQuery();     // <- Exception thrown here
 

It may be coincidental but I thought it would be remiss of me to leave it out.

Tim.

Dave Cramer wrote:

Yes,

I can confirm that it does indeed throw an exception. I will have a look
at this shortly.

Thanks,

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
> Sent: Tuesday, March 19, 2002 7:01 PM
> To: pgsql-jdbc@postgresql.org
> Subject: [JDBC] "No results were returned by the query" exceptions
>
>
> Hi people,
>
> Am I correct in assuming that the new driver now throws an
> exception when a "No results were returned by the query"
> occurs for a prepared sql statement.  I have recently
> upgraded the driver from 7.1 to 7.2 and my application now
> throws this exception when a query returns no rows in the result set.
>
> Could someone clarify this with me.
>
> Thanks,
>
> Tim Lewis
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
http://archives.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

-- 
Tim Lewis
Senior Software Engineer
Hitwise
Level 7/580 St Kilda Road
Melbourne, Victoria 3004
Phone: +61-3-8530-2400
Direct: +61-3-8530-2402
Fax  : +61-3-9529-8907
Mobile: 0414 726 899
Email: tim.lewis@hitwise.com
 

Re: "No results were returned by the query" exceptions

From
Tim Lewis
Date:
No difference.  Downloaded the driver (http://jdbc.postgresql.org/download/devpgjdbc2.jar) and have had the same problem.

It doesn't appear to have anything to do with the locking.  I have had it throw the same exception on a "select nextval ('my_sequence')" query which doesn't make any sense at all.

The machine is running an SMP kernel with two processes accessing the database (two database connections / driver instances etc).  I have been running the same code for about a month in development using the previous driver with no problems.  The development server was a single processor machine running a non-SMP kernel.

 Tim.

Dave Cramer wrote:

Tim,The latest driver which is experimental doesn't throw an exception and I copied your lock as wellcan you try it, it is the dev driver on the jdbc site.let me know what else you find, if anythingDave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
Sent: Tuesday, March 19, 2002 9:45 PM
To: Dave@micro-automation.net
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] "No results were returned by the query" exceptions
For what its worth Dave,  there are two places in my code where it the exception occurs and with both of them there is a prior statement to lock the table in share row exclusive mode. ie:

Statement st = db.createStatement();
st.executeUpdate("lock table tablex in share row exclusive mode");

String statment = "select col1 from tablex where col2 = ?";
PreparedStatement ps = db.prepareStatement(statement);
ps.setString(1, col2text);
ResultSet rs = ps.executeQuery();     // <- Exception thrown here
 

It may be coincidental but I thought it would be remiss of me to leave it out.

Tim.

Dave Cramer wrote:

Yes,

I can confirm that it does indeed throw an exception. I will have a look
at this shortly.

Thanks,

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
> Sent: Tuesday, March 19, 2002 7:01 PM
> To: pgsql-jdbc@postgresql.org
> Subject: [JDBC] "No results were returned by the query" exceptions
>
>
> Hi people,
>
> Am I correct in assuming that the new driver now throws an
> exception when a "No results were returned by the query"
> occurs for a prepared sql statement.  I have recently
> upgraded the driver from 7.1 to 7.2 and my application now
> throws this exception when a query returns no rows in the result set.
>
> Could someone clarify this with me.
>
> Thanks,
>
> Tim Lewis
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
http://archives.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org

Re: "No results were returned by the query" exceptions

From
"Dave Cramer"
Date:
Tim,
 
That driver can log the protocol. Can you send me the logs.
 
What you need to do to set it up is: insert the following code after you have loaded the driver
 
            DriverManager.setLogWriter(new java.io.PrintWriter(System.out));
            org.postgresql.Driver.setLogLevel(org.postgresql.Driver.DEBUG);
you can set System.out to a log file
 
Dave
-----Original Message-----
From: tlewis@kyle.sinewave.com.au [mailto:tlewis@kyle.sinewave.com.au] On Behalf Of Tim Lewis
Sent: Tuesday, March 19, 2002 10:49 PM
To: Dave@micro-automation.net
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] "No results were returned by the query" exceptions

No difference.  Downloaded the driver (http://jdbc.postgresql.org/download/devpgjdbc2.jar) and have had the same problem.

It doesn't appear to have anything to do with the locking.  I have had it throw the same exception on a "select nextval ('my_sequence')" query which doesn't make any sense at all.

The machine is running an SMP kernel with two processes accessing the database (two database connections / driver instances etc).  I have been running the same code for about a month in development using the previous driver with no problems.  The development server was a single processor machine running a non-SMP kernel.

 Tim.

Dave Cramer wrote:

Tim,The latest driver which is experimental doesn't throw an exception and I copied your lock as wellcan you try it, it is the dev driver on the jdbc site.let me know what else you find, if anythingDave
-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
Sent: Tuesday, March 19, 2002 9:45 PM
To: Dave@micro-automation.net
Cc: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] "No results were returned by the query" exceptions
For what its worth Dave,  there are two places in my code where it the exception occurs and with both of them there is a prior statement to lock the table in share row exclusive mode. ie:

Statement st = db.createStatement();
st.executeUpdate("lock table tablex in share row exclusive mode");

String statment = "select col1 from tablex where col2 = ?";
PreparedStatement ps = db.prepareStatement(statement);
ps.setString(1, col2text);
ResultSet rs = ps.executeQuery();     // <- Exception thrown here
 

It may be coincidental but I thought it would be remiss of me to leave it out.

Tim.

Dave Cramer wrote:

Yes,

I can confirm that it does indeed throw an exception. I will have a look
at this shortly.

Thanks,

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Tim Lewis
> Sent: Tuesday, March 19, 2002 7:01 PM
> To: pgsql-jdbc@postgresql.org
> Subject: [JDBC] "No results were returned by the query" exceptions
>
>
> Hi people,
>
> Am I correct in assuming that the new driver now throws an
> exception when a "No results were returned by the query"
> occurs for a prepared sql statement.  I have recently
> upgraded the driver from 7.1 to 7.2 and my application now
> throws this exception when a query returns no rows in the result set.
>
> Could someone clarify this with me.
>
> Thanks,
>
> Tim Lewis
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
http://archives.postgresql.org

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org