Skip site navigation (1) Skip section navigation (2)

Re: [GENERAL] jdbc driver, error trapping.

From: Peter T Mount <peter(at)retep(dot)org(dot)uk>
To: Matthew Taylor <bmatthewtaylor(at)hotmail(dot)com>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [GENERAL] jdbc driver, error trapping.
Date: 2001-01-25 09:26:03
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-generalpgsql-jdbc
Quoting Matthew Taylor <bmatthewtaylor(at)hotmail(dot)com>:

Redirected to pgsql-jdbc(at)postgresql(dot)org

> I might have missed the obvious, but currently having the following 
> behaviour.
> If I run the following java code,
> try{
> ResultSet rs = stmt.executeQuery("select blah from blah");
> while(
> {
> System.out.println("result = "+rs.getString("blah") );
> }
> rs.close();
> }catch (Exception ex)
> {
> System.out.println("error="+ex.toString() );
> }
> on a table that has NO records in it, I get an error thrown 'No results
> were 
> returned by the query'. I would like to keep the try catch blocks since
> 1. I am converting from Oracle backend which works fine otherwise.
> 2. some of my sql is dynamically generated, hence the try catch normally
> only picks up bad sql.
> any suggestions?? It's late and I'm prol not thinking straight...

Hmmm, your code shouldn't be throwing SQLException, but be returning an empty 
ResultSet. What happens if you run your query through psql?

The exception you are seeing is where the backend is not returning anything, 
not even an empty result set.


Peter Mount peter(at)retep(dot)org(dot)uk
PostgreSQL JDBC Driver:
RetepPDF PDF library for Java:

In response to

pgsql-jdbc by date

Next:From: Michael StephensonDate: 2001-01-25 09:54:41
Subject: Re: [PATCHES] Re: [INTERFACES] Patch for JDBC timestamp problems
Previous:From: Peter T MountDate: 2001-01-25 09:22:46
Subject: Re: Re: Postgresql JDBC driver - Support for Scrollable Result Sets

pgsql-general by date

Next:From: Dr R.AdscheidDate: 2001-01-25 09:38:24
Subject: vacuum
Previous:From: Ronnie EsguerraDate: 2001-01-25 08:46:32
Subject: database transfer

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group