Re: NullPointerException on call to next() - Mailing list pgsql-jdbc

From Dave Cramer
Subject Re: NullPointerException on call to next()
Date
Msg-id 00a301c16e42$92324730$c201a8c0@inspiron
Whole thread Raw
In response to NullPointerException on call to next()  ("Martin Dillard" <martin@edusoftinc.com>)
List pgsql-jdbc
Martin,
 
No this should work. I had a look at the spec and you should be able to create multiple statements on the same connection and close the inner one as many times as you want without affecting the outer statement.
Can you send me enough code to recreate the problem?
 
Dave
-----Original Message-----
From: Martin Dillard [mailto:martin@edusoftinc.com]
Sent: November 15, 2001 8:57 PM
To: Dave@micro-automation.net
Subject: Re: [JDBC] NullPointerException on call to next()

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
I just tried that also and I get the same NullPointerException.
Besides checking to make sure that the Statement is not closed or
executed with a new query before I call result.next(), is there
anything else that could be causing this?
 
Thanks for your help.
- ----- Original Message -----
From: Dave Cramer
To: 'Martin Dillard'
Sent: Thursday, November 15, 2001 5:33 PM
Subject: RE: [JDBC] NullPointerException on call to next()
 

try the 7.2 beta jar that is the latest code
 
Dave
 
- -----Original Message-----
From: Martin Dillard [mailto:martin@edusoftinc.com]
Sent: November 15, 2001 8:21 PM
To: Dave@micro-automation.net
Subject: Re: [JDBC] NullPointerException on call to next()
 

- -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
Yeah, I downloaded jdbc7.1-1.2.jar from there already and tried it.
The code breaks with that driver but works fine with the previous
driver. I scoured my code for anything that broke the contract for
the JDBC API but couldn't find anything. Would there be any problems
with using the previous driver with the latest release of Postgres as
long as it fixes my problem?
- - ----- Original Message -----
From: Dave Cramer
To: 'Martin Dillard' ; pgsql-jdbc@postgresql.org
Sent: Thursday, November 15, 2001 5:08 PM
Subject: RE: [JDBC] NullPointerException on call to next()
 

Martin,
 
You should probably try to use the latest driver from
jdbc.postgresql.org
 
This is the latest code,
 
Dave
- - -----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Martin Dillard
Sent: November 15, 2001 7:51 PM
To: pgsql-jdbc@postgresql.org
Subject: Re: [JDBC] NullPointerException on call to next()
 

- - -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
I can solve this problem by replacing the current JDBC driver with
the 7.0 driver. What changed between the two versions and is anything
affected by using the outdated driver?
- - - ----- Original Message -----
From: Martin Dillard
To: pgsql-jdbc@postgresql.org
Sent: Thursday, November 15, 2001 12:44 PM
Subject: NullPointerException on call to next()
 

- - - -----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
 
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);
           
            while (result.next())
            {
                myObject = populateFromResult(result, true, pConn);
               
                myArrayList.add(myObject);
            }
 
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
ResultSet is:
 
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?
______________________
Martin Dillard
Edusoft
martin@edusoftinc.com
 
 
- - - -----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use
<http://www.pgp.com>
 
iQA/AwUBO/QpKBiVliUcvJG9EQKxGQCePh9oLVFJ4dde8EcYzrBbt2kHdJIAn3oA
gaP82uKhG/iWOUpXnv7+9yXm
=YWFG
- - - -----END PGP SIGNATURE-----
 
- - -----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use
<http://www.pgp.com>
 
iQA/AwUBO/Ri5RiVliUcvJG9EQK+sgCbBoR9QiQsF212tJyc1Dpi43NWzjUAmwT5
vqyK/Kg2sGFb1WEOp0wqVrfa
=eTl4
- - -----END PGP SIGNATURE-----
 
- -----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use
<http://www.pgp.com>
 
iQA/AwUBO/RqABiVliUcvJG9EQJdxgCeMPhlDktTQjZm68wx1ZABUbG9pOQAoJak
FuKVuiXfhndRkpgibUYaxNax
=KrQa
- -----END PGP SIGNATURE-----
 
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com>
 
iQA/AwUBO/RycBiVliUcvJG9EQKFfgCfTzBzzNMjdgmDcOCNw2OfmO4B82QAniUg
7Mrn9Omwl657rhIfG6/zDdkY
=zdjX
-----END PGP SIGNATURE-----

pgsql-jdbc by date:

Previous
From: "Dave Cramer"
Date:
Subject: Re: NullPointerException on call to next()
Next
From: "Mike Cannon-Brookes"
Date:
Subject: Retrieving bytea column problem - they're are sometimes truncated