Re: NullPointerException atorg.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)

Поиск
Список
Период
Сортировка
От Dave Cramer
Тема Re: NullPointerException atorg.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
Дата
Msg-id 00ab01c1d64b$0d17f650$807ba8c0@inspiron
обсуждение исходный текст
Ответ на NullPointerException at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)  (Wim Ceulemans <wceulemans@keyware.com>)
Список pgsql-jdbc
Wim,

This is from the java.sql docs

Only one ResultSet object per Statement object can be open at any point
in time. Therefore, if the reading of one ResultSet object is
interleaved with the reading of another, each must have been generated
by different Statement objects. All statement execute methods implicitly
close a statment's current ResultSet object if an open one exists.

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Wim Ceulemans
> Sent: Thursday, March 28, 2002 6:13 AM
> To: pgsql-jdbc@postgresql.org
> Cc: aongena@keyware.com
> Subject: [JDBC] NullPointerException
> atorg.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
>
>
> Hi
>
> I am having problems upgrading my application from postgresql
> 7.0.2 to 7.2 with the new JDBC driver.
>
> I have managed to produce a small test program that
> illustrates the problem. The problem is that in my
> application I only use one Statement (a static instance that
> is never closed), and I re-use that statement to do all my
> queries. This worked in the JDBC driver up until 7.0.2.
>
> Now this does not seem to work anymore, I'm not sure if this
> is a bug or something I do wrong with respect to the JDBC specs.
>
> The following program works in older JDBC drivers, but now
> gives the error as in the subject of my E-mail: (note that I
> re-use the statement before I process the result set)
>
> /*
>  * @(#)Test1.java
>  *
>  */
>
> import java.sql.Connection;
> import java.sql.DatabaseMetaData;
> import java.sql.DriverManager;
> import java.sql.ResultSet;
> import java.sql.Statement;
> import java.sql.SQLException;
>
> class Test1
> {
>     private static Connection connection;
>     private static String url = "jdbc:postgresql:able";
>     private static String driver = "org.postgresql.Driver";
>     private static String login = "postgres";
>     private static String password = "postgres";
>     private static Statement stmt;
>
>     public Test1()
>     {
>         try {
>             Class.forName(driver);
>         } catch (ClassNotFoundException e) {
>
> System.out.println("ClassNotFoundException: " + e.getMessage());
>         }
>         try {
>             connection =
> DriverManager.getConnection(url,login,password);
>             stmt = connection.createStatement();
>         } catch (SQLException ex) {
>             System.out.println(ex.getMessage());
>         }
>         ResultSet resultSet1;
>         ResultSet resultSet2;
>         try {
>             resultSet1 = stmt.executeQuery("select
> * from tlogicalpart");
>             resultSet2 = stmt.executeQuery("select
> * from tstockpart");
>             int row = 0;
>             while (resultSet1.next()) {
>                 System.out.println("row: "+row);
>                 row++;
>             }
>         } catch (SQLException ex) {
>             System.out.println(ex.getMessage());
>         }
>     }
>     public static void main(String args[])
>     {
>         new Test1();
>     }
> }
>
>
> Regards
>
>
> Wim Ceulemans
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to
> majordomo@postgresql.org)
>
>


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

Предыдущее
От: Wim Ceulemans
Дата:
Сообщение: NullPointerException at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
Следующее
От: "Elisabeth Julg"
Дата:
Сообщение: Re: Accents for TEXT