Re: [GENERAL] jdbc driver, error trapping.

Поиск
Список
Период
Сортировка
От Peter T Mount
Тема Re: [GENERAL] jdbc driver, error trapping.
Дата
Msg-id 980414763.3a6ff12b5438b@webmail.retep.org.uk
обсуждение исходный текст
Список pgsql-jdbc
Quoting Matthew Taylor <bmatthewtaylor@hotmail.com>:

Redirected to pgsql-jdbc@postgresql.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(rs.next())
> {
> 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

--
Peter Mount peter@retep.org.uk
PostgreSQL JDBC Driver: http://www.retep.org.uk/postgres/
RetepPDF PDF library for Java: http://www.retep.org.uk/pdf/

В списке pgsql-jdbc по дате отправления:

Предыдущее
От: Peter T Mount
Дата:
Сообщение: Re: Re: Postgresql JDBC driver - Support for Scrollable Result Sets
Следующее
От: Michael Stephenson
Дата:
Сообщение: Re: [PATCHES] Re: [INTERFACES] Patch for JDBC timestamp problems