Return-Path: Delivered-To: apmail-db-derby-user-archive@www.apache.org Received: (qmail 18977 invoked from network); 18 Mar 2008 23:25:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Mar 2008 23:25:07 -0000 Received: (qmail 37592 invoked by uid 500); 18 Mar 2008 23:25:03 -0000 Delivered-To: apmail-db-derby-user-archive@db.apache.org Received: (qmail 37565 invoked by uid 500); 18 Mar 2008 23:25:03 -0000 Mailing-List: contact derby-user-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Discussion" Delivered-To: mailing list derby-user@db.apache.org Received: (qmail 37554 invoked by uid 99); 18 Mar 2008 23:25:03 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2008 16:25:03 -0700 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [192.18.6.21] (HELO gmp-eb-inf-1.sun.com) (192.18.6.21) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 18 Mar 2008 23:24:14 +0000 Received: from fe-emea-09.sun.com (gmp-eb-lb-2-fe2.eu.sun.com [192.18.6.11]) by gmp-eb-inf-1.sun.com (8.13.7+Sun/8.12.9) with ESMTP id m2INOWK1012895 for ; Tue, 18 Mar 2008 23:24:34 GMT Received: from conversion-daemon.fe-emea-09.sun.com by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) id <0JXY00I018UR9K00@fe-emea-09.sun.com> (original mail from Oystein.Grovlen@Sun.COM) for derby-user@db.apache.org; Tue, 18 Mar 2008 23:24:32 +0000 (GMT) Received: from [192.168.1.101] ([80.213.47.179]) by fe-emea-09.sun.com (Sun Java System Messaging Server 6.2-8.04 (built Feb 28 2007)) with ESMTPSA id <0JXY00CGT90NKK20@fe-emea-09.sun.com> for derby-user@db.apache.org; Tue, 18 Mar 2008 23:24:32 +0000 (GMT) Date: Wed, 19 Mar 2008 00:24:25 +0100 From: =?ISO-8859-1?Q?=D8ystein_Gr=F8vlen?= Subject: Re: Re-using an existing db and archiving data In-reply-to: Sender: Oystein.Grovlen@Sun.COM To: Derby Discussion Message-id: <47E04F29.7080800@sun.com> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 8BIT References: <47DED655.8090305@fastmail.fm> <47DEF5F3.9080501@sun.com> <16112414.post@talk.nabble.com> User-Agent: Thunderbird 2.0.0.12 (Windows/20080213) X-Virus-Checked: Checked by ClamAV on apache.org It would definitely help if you could provided a call stack for the NPE. If I understand correctly, it occurs when rs. next is called. I do not think your code does what you intend it to do. I think that rs.first() followed by rs.next() will position on the second row of the result set. Hence, the values of the first row will not be accessed. Also, the code will not be very efficient for large result sets since rs.last() will in most cases materialize the entire query in order to get to the last row. -- �ystein Mark Hiles wrote: > Ok, need a little guidance again.. > > I perform a query which returns some results that I'd like to store in a > 2-dimensional array. But when I try running a loop to go through the results, I > get a null pointer exception happening. I know that the query is returning 2 > rows of results, so why can't I go through them? > > Here's an example of the kind of thing I'm trying to do... > > rs = stmt.executeQuery("..."); > rs.last(); > arr = new String[rs.getRow()][2]; > rs.first(); > int i; > for(i = 0; rs.next(); ++i) { // null pointer exception > arr[i][0] = rs.getString("..."); > arr[i][1] = rs.getInt("..."); > } > > >