-----BEGIN PGP SIGNED MESSAGE-----
A NullPointerException is being thrown from a call to next() in this
(simplified) code snippet:
String sql = "SELECT * FROM my_table";
stmt = pConn.createStatement();
result = stmt.executeQuery(sql);
myObject = populateFromResult(result, true, pConn);
The exception is thrown in the second iteration of the while loop
from result.next(). The method populateFromResult only calls getXXX()
methods on the ResultSet and creates another Statement on the
Connection and uses it to populate other fields in the object. The
Connection and the ResultSet are not closed. The new Statement on the
Connection IS CLOSED (could this be the problem???).
After decompiling the jdbc drivers, the offending line of code inside
if (++current_row >= rows.size())
I am using the JDBC drivers compiled from the 7.1.3 release of
Postgres running on Tomcat in Linux. The same code works fine on the
drivers from the 7.1RC2 release running on Resin in Windows.
The only previous posts I have found describing this problem
concluded that the problem was caused by closing the Statement or
executing a new query on it before the subsequent call to next(). I
have examined my code closely and am not using the ResultSet or
Statement for anything other than what you see in the code above.
Has anyone run across this problem? Does anyone have any suggestions?
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>
-----END PGP SIGNATURE-----
pgsql-jdbc by date
|Next:||From: Martin Dillard||Date: 2001-11-16 00:50:46|
|Subject: Re: NullPointerException on call to next()|
|Previous:||From: Tomisław Kityński||Date: 2001-11-15 15:01:54|
|Subject: executeUpdate() --- what does it actually return?|