Re: java.lang.NullPointerException on imbricated queries

Поиск
Список
Период
Сортировка
От Garrick Dasbach
Тема Re: java.lang.NullPointerException on imbricated queries
Дата
Msg-id 1056982076.28364.1.camel@bock
обсуждение исходный текст
Ответ на Re: java.lang.NullPointerException on imbricated queries  ("Kallol Nandi" <kallol.nandi@indussoft.com>)
Список pgsql-jdbc
Each Statement may only have 1 ResultSet open at a time.  If you want to
access multiple Results at the same time, you need to use 2 different
Statements.  See below

1       Query1 = "SELECT * FROM example1;";
2       rs1 = stmt1.executeQuery(Query1);
3       while (rs1.next()) {
4               Query2 = "SELECT * FROM example2;
5               rs2 = stmt2.executeQuery(Query2);
6               while (rs2.next()) {
7                       // Something .../...
8               }
9       }

Garrick

On Mon, 2003-06-30 at 04:06, Kallol Nandi wrote:
> Are you using GNU's jdk or Sun's jdk?
>
> Regards,
> Kallol.
>   -----Original Message-----
>   From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org]On Behalf Of Olivier BULLAT
>   Sent: Monday, June 30, 2003 2:29 PM
>   To: pgsql-jdbc@postgresql.org
>   Subject: [JDBC] java.lang.NullPointerException on imbricated queries
>
>
>   Hello,
>
>   We have a web application in Apache, Posgresql 7.2, servlet java (JDK
> 1.2), Jserv and jdbc7.2dev-1.2.jar.
>   A lot of programs runs normally with JDBC access to postgresql. But when
> we use two imbricated queries like this example, a message JAVALANGEXEPTION
> java.lang.NullPointerException occurs:
>
>   1       Query1 = "SELECT * FROM example1;";
>   2       rs1 = stmt.executeQuery(Query1);
>   3       while (rs1.next()) {
>   4               Query2 = "SELECT * FROM example2;
>   5               rs2 = stmt.executeQuery(Query2);
>   6               while (rs2.next()) {
>   7                       // Something .../...
>   8               }
>   9       }
>
>   Programme DetailsRapports.java: JAVALANGEXEPTION
> java.lang.NullPointerException:
>   java.lang.NullPointerException:
>           at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
>           at DetailsRapports.AfficheEntrees(DetailsRapports.java:68)
>           at DetailsRapports.service(DetailsRapports.java:43)
>           at javax.servlet.http.HttpServlet.service(HttpServlet.java:588)
>           at
> org.apache.jserv.JServConnection.processRequest(JServConnection.java:317)
>           at org.apache.jserv.JServConnection.run(JServConnection.java:188)
>           at java.lang.Thread.run(Thread.java:479)
>
>   This message occurs on line 3 "while (rs1.next()) {" after a first good
> Query1 and a first good Query2.
>
>   Any help would be appreciated.
>
>
>
>   --------------------------------------------------------------------------
>   Olivier BULLAT
>   Responsable du Centre de Ressources Informatiques
>   Institut Francais de Mecanique Avancee - IFMA
>   Campus de CLERMONT-FERRAND / Les Cezeaux
>   BP 265
>   63175 AUBIERE Cedex
>   Tel:   04.73.28.80.35
>   Fax:  04.73.28.81.00
>   mail: Olivier.Bullat@ifma.fr
>   http://www.ifma.fr
>   --------------------------------------------------------------------------
>



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

Предыдущее
От: "Kallol Nandi"
Дата:
Сообщение: Re: java.lang.NullPointerException on imbricated queries
Следующее
От: Barry Lind
Дата:
Сообщение: Re: [PATCHES] Add checking in setMaxRows, setQueryTimeout, and setFetchSize