Re: "No Results were returned by the query" exception

From: Dave Cramer <Dave(at)micro-automation(dot)net>
To: Jon Swinth <jswinth(at)atomicpc(dot)com>
Cc: Joe Shevland <jshevland(at)j-elite(dot)com>, "pgsql-jdbc(at)postgresql(dot)org" <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: "No Results were returned by the query" exception
Date: 2002-06-07 00:19:09
Message-ID: 1023409149.1646.692.camel@inspiron.cramers
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Jon,

then chances are the insert is failing and then the transaction needs to
be rolledback. Once a transaction has an error it cannot be used until
ended, by either rollback, or commit

Dave
On Thu, 2002-06-06 at 20:01, Jon Swinth wrote:
> Thanks for the reply Joe.
>
> I am using PostGreSQL 7.2.1 with JDBC driver of http://jdbc.postgresql.org/download/devpgjdbc2.jar.
>
> Code is:
>
> public int getNextValue(
> String sequenceName )
> throws SQLException {
> checkAll(sequenceName);
> Statement s = null ;
> ResultSet rs = null ;
> try {
> s = connection.createStatement() ;
> rs = s.executeQuery("SELECT nextval('"+sequenceName+"')");
> if (!rs.next()) {
> throw new SQLException("No Rows Returned from Sequence " + sequenceName);
> } //end if
> int returnValue = rs.getInt(1) ;
> rs.close();
> s.close();
> return returnValue ;
> } catch (SQLException e) {
> if (rs != null) {
> rs.close();
> } //end if
> if (s != null) {
> s.close();
> } //end if
> throw e ;
> } //end try
> } //end getNextValue()
>
> And yes I am using it from within a transaction.
>
> What is odd is it is not consistant. This same code runs fine for a lot of things.
>
> My guess is that there is a variable that is not being reset properly in the driver. That would explain why
> it does not happen all the time. In this case, I am receiving an error when running the above code after an
> INSERT statement on the same connection.
>
> Jon
>
> On Thursday 06 June 2002 04:02 pm, Joe Shevland wrote:
> > Sorry I'm not across the actual issue, but have you got a small snippet of
> > Java code to demonstrate the problem (enough to see if its inside a
> > transaction etc and how you're executing the statement and looping through
> > the RS)? Also the version number of the PostgreSQL backend.
> >
> > I do the below sort of thing regularly and haven't had a problem. The
> > drivers on http://jdbc.postgresql.org/download are the best ones to go for
> > if you're not already using those.
> >
> > Cheers,
> > Joe
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Jon Swinth 2002-06-07 00:56:34 Re: "No Results were returned by the query" exception
Previous Message Jon Swinth 2002-06-07 00:01:46 Re: "No Results were returned by the query" exception