Thread: NullPointerException on next()
Using the jdbc 7.1.2 drivers: Exception in thread "main" java.lang.NullPointerException at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:116) that line is: if (++current_row >= rows.size()) -- Joseph Shraibman jks@selectacast.net Increase signal to noise ratio. http://www.targabot.com
Joseph, Can you post some code to reproduce the error please? Dave -----Original Message----- From: pgsql-jdbc-owner@postgresql.org [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Joseph Shraibman Sent: August 9, 2001 9:27 PM To: pgsql-jdbc@postgresql.org Subject: [JDBC] NullPointerException on next() Using the jdbc 7.1.2 drivers: Exception in thread "main" java.lang.NullPointerException at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:116) that line is: if (++current_row >= rows.size()) -- Joseph Shraibman jks@selectacast.net Increase signal to noise ratio. http://www.targabot.com ---------------------------(end of broadcast)--------------------------- TIP 4: Don't 'kill -9' the postmaster
Check that you didn't close the statement before making this call to next() in the ResultSet object. Tom. On Thu, Aug 09, 2001 at 09:34:51PM -0400, Dave Cramer wrote: > Joseph, > > Can you post some code to reproduce the error please? > > Dave > > -----Original Message----- > From: pgsql-jdbc-owner@postgresql.org > [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Joseph Shraibman > Sent: August 9, 2001 9:27 PM > To: pgsql-jdbc@postgresql.org > Subject: [JDBC] NullPointerException on next() > > > Using the jdbc 7.1.2 drivers: > > Exception in thread "main" java.lang.NullPointerException > at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:116) > > that line is: > if (++current_row >= rows.size()) > > -- > Joseph Shraibman > jks@selectacast.net > Increase signal to noise ratio. http://www.targabot.com > > > ---------------------------(end of broadcast)--------------------------- > TIP 4: Don't 'kill -9' the postmaster > > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org -- Thomas O'Dowd. - Nooping - http://nooper.com tom@nooper.com - Testing - http://nooper.co.jp/labs
I didn't close the statement. I did use the statement again (to do an update) before I called next(), is that a problem now? Thomas O'Dowd wrote: > Check that you didn't close the statement before making this > call to next() in the ResultSet object. > > Tom. > > On Thu, Aug 09, 2001 at 09:34:51PM -0400, Dave Cramer wrote: > >>Joseph, >> >>Can you post some code to reproduce the error please? >> >>Dave >> >>-----Original Message----- >>From: pgsql-jdbc-owner@postgresql.org >>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Joseph Shraibman >>Sent: August 9, 2001 9:27 PM >>To: pgsql-jdbc@postgresql.org >>Subject: [JDBC] NullPointerException on next() >> >> >>Using the jdbc 7.1.2 drivers: >> >>Exception in thread "main" java.lang.NullPointerException >> at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:116) >> >>that line is: >> if (++current_row >= rows.size()) >> >>-- >>Joseph Shraibman >>jks@selectacast.net >>Increase signal to noise ratio. http://www.targabot.com >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 4: Don't 'kill -9' the postmaster >> >> >> >>---------------------------(end of broadcast)--------------------------- >>TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >> > -- Joseph Shraibman jks@selectacast.net Increase signal to noise ratio. http://www.targabot.com
On Fri, 10 Aug 2001 14:06:08 -0400, you wrote: >I didn't close the statement. I did use the statement again (to do an >update) before I called next(), is that a problem now? Yes. Closing or re-executing the statement closes its ResultSet. This is per the JDBC spec, its not PostgreSQL-specific. Regards, René Pijlman
I think it used to work. Anyway maybe an IllegalStateException should be thrown instead of NullPointerException? Rene Pijlman wrote: > On Fri, 10 Aug 2001 14:06:08 -0400, you wrote: > >>I didn't close the statement. I did use the statement again (to do an >>update) before I called next(), is that a problem now? >> > > Yes. Closing or re-executing the statement closes its ResultSet. > This is per the JDBC spec, its not PostgreSQL-specific. > > Regards, > René Pijlman > -- Joseph Shraibman jks@selectacast.net Increase signal to noise ratio. http://www.targabot.com
Yep, it used to work. I got caught by it too after an upgrade :) I think you're right about the exception that's being thrown, it shouldn't be the NullPointerException. Tom. On Fri, Aug 10, 2001 at 03:26:41PM -0400, Joseph Shraibman wrote: > I think it used to work. Anyway maybe an IllegalStateException should > be thrown instead of NullPointerException? > > > Rene Pijlman wrote: > > On Fri, 10 Aug 2001 14:06:08 -0400, you wrote: > > > >>I didn't close the statement. I did use the statement again (to do an > >>update) before I called next(), is that a problem now? > >> > > > > Yes. Closing or re-executing the statement closes its ResultSet. > > This is per the JDBC spec, its not PostgreSQL-specific. > > > > Regards, > > René Pijlman > > > > > -- > Joseph Shraibman > jks@selectacast.net > Increase signal to noise ratio. http://www.targabot.com > > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/users-lounge/docs/faq.html -- Thomas O'Dowd. - Nooping - http://nooper.com tom@nooper.com - Testing - http://nooper.co.jp/labs
On Sat, 11 Aug 2001 11:40:29 +0900, you wrote: >I think you're right about the exception that's being thrown, >it shouldn't be the NullPointerException. I've put it on the todo list: http://lab.applinet.nl/postgresql-jdbc/ ("ResultSet"). It should throw a java.sql.SQLException, however, instead of a java.lang.IllegalStateException. See the JDBC book (http://java.sun.com/docs/books/jdbc/) section A.4: "There are cases where a JavaRunTimeException and an SQLException might overlap. ... In such cases, it is recommended that the SQLException be thrown because that gives JDBC more consistent control over errors." Regards, René Pijlman