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

From: Wim Ceulemans <wceulemans(at)keyware(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Cc: aongena(at)keyware(dot)com
Subject: NullPointerException at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
Date: 2002-03-28 11:13:18
Message-ID: 1017313998.14078.25.camel@wc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2002-03-28 11:23:56 Re: NullPointerException atorg.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
Previous Message Dave Cramer 2002-03-28 10:27:41 Re: Error on commi()