Обсуждение: JDBC ResultSet

Поиск
Список
Период
Сортировка

JDBC ResultSet

От
Stoffel van Aswegen
Дата:
I have the following Java code:

---snip---
    ResultSet rst = pgConnection.openResultSet("SELECT foo, bar from
table1");
    while (rst.next))
        System.out.println(rst.getString("foo"),
rst.getString("bar"));
---snip---
[I'm writing from memory - not sure if openResultSet is the correct method
name.]

This always only prints _one_ record, which is also the last record. The
docs say that the cursor opens before the first record, so I must be doing
something wrong.

I am using PostgreSQL 6.5 database (yes, I know it's old, but I'm only
playing/learning/prototyping/...) Surely, this is not a pg6.5 problem? Or is
it?

I'd appreciate any pointers.
TIA

Stoffel van Aswegen
import signature.*;


Re: JDBC ResultSet

От
"Josh Berkus"
Дата:
Stoffel,

> I am using PostgreSQL 6.5 database (yes, I know it's old, but I'm
> only
> playing/learning/prototyping/...) Surely, this is not a pg6.5
> problem? Or is
> it?

1. You should upgrade.  There are a *lot* of things in 6.5 that don't
work right, and if you don't upgrade you'll never be sure what's your
code and what's a PostgreSQL bug.  Also, 7.1.3 supports a lot more SQL
92 than 6.5 does (left joins, subselects in the FROM clause, etc.).

2. Join the pgsql-jdbc list and post your question there.  That's where
it's most likely to get answered.

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
                                       Josh Berkus
  Complete information technology      josh@agliodbs.com
   and data management solutions       (415) 565-7293
  for law firms, small businesses        fax 621-2533
    and non-profit organizations.      San Francisco

Вложения