NullPointerException at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)

Поиск
Список
Период
Сортировка
От Wim Ceulemans
Тема NullPointerException at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
Дата
Msg-id 1017313998.14078.25.camel@wc
обсуждение исходный текст
Ответы Re: NullPointerException atorg.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)  ("Dave Cramer" <Dave@micro-automation.net>)
Список pgsql-jdbc
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



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

Предыдущее
От: "Dave Cramer"
Дата:
Сообщение: Re: Error on commi()
Следующее
От: "Dave Cramer"
Дата:
Сообщение: Re: NullPointerException atorg.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)