Thread: NullPointer at ResultSet.java:113

NullPointer at ResultSet.java:113

From
Hans Deragon
Date:
Greetings.


   Upgraded yesterday to the latest pgjdbc2.jar.  I am using JDK 1.4.0.
  My database is postgresql-7.1.3-2.  I get:

         at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
         at marketmanager.database.StockSymbol.list(StockSymbol.java:93)
         at
marketmanager.datacollection.stocks.YahooCollector.fetchDataFromWeb(YahooCollector.java:56)
         at
marketmanager.datacollection.stocks.YahooCollector.fetchData(YahooCollector.java:111)
         at marketmanager.datacollection.FetchData.main(FetchData.java:13)

   This is a bug for sure.  If there is something wrong I am doing, then
it should have been caught by an exception and report to me what I was
doing wrong.  My code works with an older version of the postgresql jdbc
driver.  And my code is pretty basic.

   I could not find on the development website the source of this code.
  Anybody can provide a pointer?  May I suggest a direct hyperlink to
the code to the development site from the http://jdbc.postgresql.org/?


Ciao
Hans


Re: NullPointer at ResultSet.java:113

From
"Dave Cramer"
Date:
Hans,

Generally this means that there is nothing in the result set. Can you
give me some code which demonstrates this bug?

Dave

-----Original Message-----
From: pgsql-jdbc-owner@postgresql.org
[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
Sent: Saturday, March 09, 2002 6:13 AM
To: pgsql-jdbc
Subject: [JDBC] NullPointer at ResultSet.java:113


Greetings.


   Upgraded yesterday to the latest pgjdbc2.jar.  I am using JDK 1.4.0.
  My database is postgresql-7.1.3-2.  I get:

         at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
         at marketmanager.database.StockSymbol.list(StockSymbol.java:93)
         at
marketmanager.datacollection.stocks.YahooCollector.fetchDataFromWeb(Yaho
oCollector.java:56)
         at
marketmanager.datacollection.stocks.YahooCollector.fetchData(YahooCollec
tor.java:111)
         at
marketmanager.datacollection.FetchData.main(FetchData.java:13)

   This is a bug for sure.  If there is something wrong I am doing, then

it should have been caught by an exception and report to me what I was
doing wrong.  My code works with an older version of the postgresql jdbc

driver.  And my code is pretty basic.

   I could not find on the development website the source of this code.
  Anybody can provide a pointer?  May I suggest a direct hyperlink to
the code to the development site from the http://jdbc.postgresql.org/?


Ciao
Hans


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/users-lounge/docs/faq.html



Re: NullPointer at ResultSet.java:113

From
Hans Deragon
Date:
Found the problem.  I do:

   public static void main(String argv[]) throws Exception
   {
     Class.forName("org.postgresql.Driver");
     Connection m_connection =
       DriverManager.getConnection(DATABASEURL, USERNAME, PASSWORD);

     ResultSet rs =null;
     {
       Statement st = m_connection.createStatement();
       rs = st.executeQuery("SELECT * FROM stocksymbol");
       st.close(); // <------ Problem!
     }

     System.err.println("\nHANS1" + rs);
     rs.beforeFirst();
     System.err.println("\nHANS1b");
     while(rs.next())
     {
       System.err.println("\nHANS2\n");
     }

As you can see, the statement is closed before the ResultSet is used.
It used to work with old Postgresql drivers, but not the most recent.  I
  will simply remove the st.close() statement in my close.  I assume
that there is a finalize() function in the Statement such that the close
is done automatically when the instance is disposed.

Still, it would be nice if we got a nice exception instead of a
NullPointer exception.  Can someone correct the code to generate such
exception?

Sorry for the delay for my response. Its a pet project I am working on,
on spare time.


Sincerely,
Hans Deragon

Dave Cramer wrote:

> Hans,
>
> Generally this means that there is nothing in the result set. Can you
> give me some code which demonstrates this bug?
>
> Dave
>
> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
> Sent: Saturday, March 09, 2002 6:13 AM
> To: pgsql-jdbc
> Subject: [JDBC] NullPointer at ResultSet.java:113
>
>
> Greetings.
>
>
>    Upgraded yesterday to the latest pgjdbc2.jar.  I am using JDK 1.4.0.
>   My database is postgresql-7.1.3-2.  I get:
>
>          at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
>          at marketmanager.database.StockSymbol.list(StockSymbol.java:93)
>          at
> marketmanager.datacollection.stocks.YahooCollector.fetchDataFromWeb(Yaho
> oCollector.java:56)
>          at
> marketmanager.datacollection.stocks.YahooCollector.fetchData(YahooCollec
> tor.java:111)
>          at
> marketmanager.datacollection.FetchData.main(FetchData.java:13)
>
>    This is a bug for sure.  If there is something wrong I am doing, then
>
> it should have been caught by an exception and report to me what I was
> doing wrong.  My code works with an older version of the postgresql jdbc
>
> driver.  And my code is pretty basic.
>
>    I could not find on the development website the source of this code.
>   Anybody can provide a pointer?  May I suggest a direct hyperlink to
> the code to the development site from the http://jdbc.postgresql.org/?
>
>
> Ciao
> Hans
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
>
>
>
>



Re: NullPointer at ResultSet.java:113

From
"Dave Cramer"
Date:
Hans,

I rebuilt the 7.2dev driver on the download site. Let me know if that
fixes your problem

Dave

> -----Original Message-----
> From: pgsql-jdbc-owner@postgresql.org
> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
> Sent: Thursday, March 14, 2002 6:42 PM
> To: Dave@micro-automation.net
> Cc: 'pgsql-jdbc'
> Subject: Re: [JDBC] NullPointer at ResultSet.java:113
>
>
> Found the problem.  I do:
>
>    public static void main(String argv[]) throws Exception
>    {
>      Class.forName("org.postgresql.Driver");
>      Connection m_connection =
>        DriverManager.getConnection(DATABASEURL, USERNAME, PASSWORD);
>
>      ResultSet rs =null;
>      {
>        Statement st = m_connection.createStatement();
>        rs = st.executeQuery("SELECT * FROM stocksymbol");
>        st.close(); // <------ Problem!
>      }
>
>      System.err.println("\nHANS1" + rs);
>      rs.beforeFirst();
>      System.err.println("\nHANS1b");
>      while(rs.next())
>      {
>        System.err.println("\nHANS2\n");
>      }
>
> As you can see, the statement is closed before the ResultSet is used.
> It used to work with old Postgresql drivers, but not the most
> recent.  I
>   will simply remove the st.close() statement in my close.  I assume
> that there is a finalize() function in the Statement such
> that the close
> is done automatically when the instance is disposed.
>
> Still, it would be nice if we got a nice exception instead of a
> NullPointer exception.  Can someone correct the code to generate such
> exception?
>
> Sorry for the delay for my response. Its a pet project I am
> working on,
> on spare time.
>
>
> Sincerely,
> Hans Deragon
>
> Dave Cramer wrote:
>
> > Hans,
> >
> > Generally this means that there is nothing in the result
> set. Can you
> > give me some code which demonstrates this bug?
> >
> > Dave
> >
> > -----Original Message-----
> > From: pgsql-jdbc-owner@postgresql.org
> > [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
> > Sent: Saturday, March 09, 2002 6:13 AM
> > To: pgsql-jdbc
> > Subject: [JDBC] NullPointer at ResultSet.java:113
> >
> >
> > Greetings.
> >
> >
> >    Upgraded yesterday to the latest pgjdbc2.jar.  I am
> using JDK 1.4.0.
> >   My database is postgresql-7.1.3-2.  I get:
> >
> >          at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
> >          at
> marketmanager.database.StockSymbol.list(StockSymbol.java:93)
> >          at
> >
> marketmanager.datacollection.stocks.YahooCollector.fetchDataFr
> omWeb(Yaho
> > oCollector.java:56)
> >          at
> >
> marketmanager.datacollection.stocks.YahooCollector.fetchData(Y
> ahooCollec
> > tor.java:111)
> >          at
> > marketmanager.datacollection.FetchData.main(FetchData.java:13)
> >
> >    This is a bug for sure.  If there is something wrong I am doing,
> > then
> >
> > it should have been caught by an exception and report to me
> what I was
> > doing wrong.  My code works with an older version of the
> postgresql jdbc
> >
> > driver.  And my code is pretty basic.
> >
> >    I could not find on the development website the source
> of this code.
> >   Anybody can provide a pointer?  May I suggest a direct
> hyperlink to
> > the code to the development site from the
> http://jdbc.postgresql.org/?
> >
> >
> > Ciao
> > Hans
> >
> >
> >
> ---------------------------(end of
> > broadcast)---------------------------
> > TIP 5: Have you checked our extensive FAQ?
> >
> > http://www.postgresql.org/users-lounge/docs/faq.html
> >
> >
> >
> >
>
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
http://archives.postgresql.org



Re: NullPointer at ResultSet.java:113

From
Hans Deragon
Date:
Hi Dave.


   I do not see a difference.  If I close a Statement, I still get later
a NullPointerException.

   I have a question, should I actually close a Statement at that point
or not?  I have no clue what I am supposed to do. For the moment, I
removed the st.close() statement in my code.  Performance and resource
management are not on my list of priorities.


Sincerely,
Hans Deragon

Dave Cramer wrote:

> Hans,
>
> I rebuilt the 7.2dev driver on the download site. Let me know if that
> fixes your problem
>
> Dave
>
>
>>-----Original Message-----
>>From: pgsql-jdbc-owner@postgresql.org
>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
>>Sent: Thursday, March 14, 2002 6:42 PM
>>To: Dave@micro-automation.net
>>Cc: 'pgsql-jdbc'
>>Subject: Re: [JDBC] NullPointer at ResultSet.java:113
>>
>>
>>Found the problem.  I do:
>>
>>   public static void main(String argv[]) throws Exception
>>   {
>>     Class.forName("org.postgresql.Driver");
>>     Connection m_connection =
>>       DriverManager.getConnection(DATABASEURL, USERNAME, PASSWORD);
>>
>>     ResultSet rs =null;
>>     {
>>       Statement st = m_connection.createStatement();
>>       rs = st.executeQuery("SELECT * FROM stocksymbol");
>>       st.close(); // <------ Problem!
>>     }
>>
>>     System.err.println("\nHANS1" + rs);
>>     rs.beforeFirst();
>>     System.err.println("\nHANS1b");
>>     while(rs.next())
>>     {
>>       System.err.println("\nHANS2\n");
>>     }
>>
>>As you can see, the statement is closed before the ResultSet is used.
>>It used to work with old Postgresql drivers, but not the most
>>recent.  I
>>  will simply remove the st.close() statement in my close.  I assume
>>that there is a finalize() function in the Statement such
>>that the close
>>is done automatically when the instance is disposed.
>>
>>Still, it would be nice if we got a nice exception instead of a
>>NullPointer exception.  Can someone correct the code to generate such
>>exception?
>>
>>Sorry for the delay for my response. Its a pet project I am
>>working on,
>>on spare time.
>>
>>
>>Sincerely,
>>Hans Deragon
>>
>>Dave Cramer wrote:
>>
>>
>>>Hans,
>>>
>>>Generally this means that there is nothing in the result
>>>
>>set. Can you
>>
>>>give me some code which demonstrates this bug?
>>>
>>>Dave
>>>
>>>-----Original Message-----
>>>From: pgsql-jdbc-owner@postgresql.org
>>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
>>>Sent: Saturday, March 09, 2002 6:13 AM
>>>To: pgsql-jdbc
>>>Subject: [JDBC] NullPointer at ResultSet.java:113
>>>
>>>
>>>Greetings.
>>>
>>>
>>>   Upgraded yesterday to the latest pgjdbc2.jar.  I am
>>>
>>using JDK 1.4.0.
>>
>>>  My database is postgresql-7.1.3-2.  I get:
>>>
>>>         at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
>>>         at
>>>
>>marketmanager.database.StockSymbol.list(StockSymbol.java:93)
>>
>>>         at
>>>
>>>
>>marketmanager.datacollection.stocks.YahooCollector.fetchDataFr
>>omWeb(Yaho
>>
>>>oCollector.java:56)
>>>         at
>>>
>>>
>>marketmanager.datacollection.stocks.YahooCollector.fetchData(Y
>>ahooCollec
>>
>>>tor.java:111)
>>>         at
>>>marketmanager.datacollection.FetchData.main(FetchData.java:13)
>>>
>>>   This is a bug for sure.  If there is something wrong I am doing,
>>>then
>>>
>>>it should have been caught by an exception and report to me
>>>
>>what I was
>>
>>>doing wrong.  My code works with an older version of the
>>>
>>postgresql jdbc
>>
>>>driver.  And my code is pretty basic.
>>>
>>>   I could not find on the development website the source
>>>
>>of this code.
>>
>>>  Anybody can provide a pointer?  May I suggest a direct
>>>
>>hyperlink to
>>
>>>the code to the development site from the
>>>
>>http://jdbc.postgresql.org/?
>>
>>>
>>>Ciao
>>>Hans
>>>
>>>
>>>
>>>
>>---------------------------(end of
>>
>>>broadcast)---------------------------
>>>TIP 5: Have you checked our extensive FAQ?
>>>
>>>http://www.postgresql.org/users-lounge/docs/faq.html
>>>
>>>
>>>
>>>
>>>
>>
>>
>>---------------------------(end of
>>broadcast)---------------------------
>>TIP 6: Have you searched our list archives?
>>
>>
> http://archives.postgresql.org
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
>



Re: NullPointer at ResultSet.java:113

From
"Dave Cramer"
Date:
Hans,

Oh, ok, now I see what you are trying to do. No you can't close the
statement here, the result set that you are going to scroll through is
part of it.

You can close it safely after you have scrolled through the result set.
It still shouldn't throw an NPE though

Dave

> -----Original Message-----
> From: Hans Deragon [mailto:hans@deragon.biz]
> Sent: Saturday, March 16, 2002 7:26 AM
> To: Dave@micro-automation.net
> Cc: 'pgsql-jdbc'
> Subject: Re: [JDBC] NullPointer at ResultSet.java:113
>
>
> Hi Dave.
>
>
>    I do not see a difference.  If I close a Statement, I
> still get later
> a NullPointerException.
>
>    I have a question, should I actually close a Statement at
> that point
> or not?  I have no clue what I am supposed to do. For the moment, I
> removed the st.close() statement in my code.  Performance and
> resource
> management are not on my list of priorities.
>
>
> Sincerely,
> Hans Deragon
>
> Dave Cramer wrote:
>
> > Hans,
> >
> > I rebuilt the 7.2dev driver on the download site. Let me
> know if that
> > fixes your problem
> >
> > Dave
> >
> >
> >>-----Original Message-----
> >>From: pgsql-jdbc-owner@postgresql.org
> >>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
> >>Sent: Thursday, March 14, 2002 6:42 PM
> >>To: Dave@micro-automation.net
> >>Cc: 'pgsql-jdbc'
> >>Subject: Re: [JDBC] NullPointer at ResultSet.java:113
> >>
> >>
> >>Found the problem.  I do:
> >>
> >>   public static void main(String argv[]) throws Exception
> >>   {
> >>     Class.forName("org.postgresql.Driver");
> >>     Connection m_connection =
> >>       DriverManager.getConnection(DATABASEURL, USERNAME, PASSWORD);
> >>
> >>     ResultSet rs =null;
> >>     {
> >>       Statement st = m_connection.createStatement();
> >>       rs = st.executeQuery("SELECT * FROM stocksymbol");
> >>       st.close(); // <------ Problem!
> >>     }
> >>
> >>     System.err.println("\nHANS1" + rs);
> >>     rs.beforeFirst();
> >>     System.err.println("\nHANS1b");
> >>     while(rs.next())
> >>     {
> >>       System.err.println("\nHANS2\n");
> >>     }
> >>
> >>As you can see, the statement is closed before the
> ResultSet is used.
> >>It used to work with old Postgresql drivers, but not the most
> >>recent.  I
> >>  will simply remove the st.close() statement in my close.
> I assume
> >>that there is a finalize() function in the Statement such
> >>that the close
> >>is done automatically when the instance is disposed.
> >>
> >>Still, it would be nice if we got a nice exception instead of a
> >>NullPointer exception.  Can someone correct the code to
> generate such
> >>exception?
> >>
> >>Sorry for the delay for my response. Its a pet project I am
> >>working on,
> >>on spare time.
> >>
> >>
> >>Sincerely,
> >>Hans Deragon
> >>
> >>Dave Cramer wrote:
> >>
> >>
> >>>Hans,
> >>>
> >>>Generally this means that there is nothing in the result
> >>>
> >>set. Can you
> >>
> >>>give me some code which demonstrates this bug?
> >>>
> >>>Dave
> >>>
> >>>-----Original Message-----
> >>>From: pgsql-jdbc-owner@postgresql.org
> >>>[mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
> >>>Sent: Saturday, March 09, 2002 6:13 AM
> >>>To: pgsql-jdbc
> >>>Subject: [JDBC] NullPointer at ResultSet.java:113
> >>>
> >>>
> >>>Greetings.
> >>>
> >>>
> >>>   Upgraded yesterday to the latest pgjdbc2.jar.  I am
> >>>
> >>using JDK 1.4.0.
> >>
> >>>  My database is postgresql-7.1.3-2.  I get:
> >>>
> >>>         at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
> >>>         at
> >>>
> >>marketmanager.database.StockSymbol.list(StockSymbol.java:93)
> >>
> >>>         at
> >>>
> >>>
> >>marketmanager.datacollection.stocks.YahooCollector.fetchDataFr
> >>omWeb(Yaho
> >>
> >>>oCollector.java:56)
> >>>         at
> >>>
> >>>
> >>marketmanager.datacollection.stocks.YahooCollector.fetchData(Y
> >>ahooCollec
> >>
> >>>tor.java:111)
> >>>         at
> >>>marketmanager.datacollection.FetchData.main(FetchData.java:13)
> >>>
> >>>   This is a bug for sure.  If there is something wrong I am doing,
> >>>then
> >>>
> >>>it should have been caught by an exception and report to me
> >>>
> >>what I was
> >>
> >>>doing wrong.  My code works with an older version of the
> >>>
> >>postgresql jdbc
> >>
> >>>driver.  And my code is pretty basic.
> >>>
> >>>   I could not find on the development website the source
> >>>
> >>of this code.
> >>
> >>>  Anybody can provide a pointer?  May I suggest a direct
> >>>
> >>hyperlink to
> >>
> >>>the code to the development site from the
> >>>
> >>http://jdbc.postgresql.org/?
> >>
> >>>
> >>>Ciao
> >>>Hans
> >>>
> >>>
> >>>
> >>>
> >>---------------------------(end of
> >>
> >>>broadcast)---------------------------
> >>>TIP 5: Have you checked our extensive FAQ?
> >>>
> >>>http://www.postgresql.org/users-lounge/docs/faq.html
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >>---------------------------(end of
> >>broadcast)---------------------------
> >>TIP 6: Have you searched our list archives?
> >>
> >>
> > http://archives.postgresql.org
> >
> >
> >
> > ---------------------------(end of
> > broadcast)---------------------------
> > TIP 3: if posting/reading through Usenet, please send an appropriate
> > subscribe-nomail command to majordomo@postgresql.org so that your
> > message can get through to the mailing list cleanly
> >
> >
>
>
>


Re: NullPointer at ResultSet.java:113

From
Barry Lind
Date:
Hans,

I have fixed this problem in current sources.  next() no longer throws a
null pointer exception in this case.  It throws a more specific
SQLException indicating that the ResultSet is closed.

thanks,
--Barry

Hans Deragon wrote:
> Found the problem.  I do:
>
>   public static void main(String argv[]) throws Exception
>   {
>     Class.forName("org.postgresql.Driver");
>     Connection m_connection =
>       DriverManager.getConnection(DATABASEURL, USERNAME, PASSWORD);
>
>     ResultSet rs =null;
>     {
>       Statement st = m_connection.createStatement();
>       rs = st.executeQuery("SELECT * FROM stocksymbol");
>       st.close(); // <------ Problem!
>     }
>
>     System.err.println("\nHANS1" + rs);
>     rs.beforeFirst();
>     System.err.println("\nHANS1b");
>     while(rs.next())
>     {
>       System.err.println("\nHANS2\n");
>     }
>
> As you can see, the statement is closed before the ResultSet is used. It
> used to work with old Postgresql drivers, but not the most recent.  I
>  will simply remove the st.close() statement in my close.  I assume that
> there is a finalize() function in the Statement such that the close is
> done automatically when the instance is disposed.
>
> Still, it would be nice if we got a nice exception instead of a
> NullPointer exception.  Can someone correct the code to generate such
> exception?
>
> Sorry for the delay for my response. Its a pet project I am working on,
> on spare time.
>
>
> Sincerely,
> Hans Deragon
>
> Dave Cramer wrote:
>
>> Hans,
>>
>> Generally this means that there is nothing in the result set. Can you
>> give me some code which demonstrates this bug?
>>
>> Dave
>>
>> -----Original Message-----
>> From: pgsql-jdbc-owner@postgresql.org
>> [mailto:pgsql-jdbc-owner@postgresql.org] On Behalf Of Hans Deragon
>> Sent: Saturday, March 09, 2002 6:13 AM
>> To: pgsql-jdbc
>> Subject: [JDBC] NullPointer at ResultSet.java:113
>>
>>
>> Greetings.
>>
>>
>>    Upgraded yesterday to the latest pgjdbc2.jar.  I am using JDK
>> 1.4.0.   My database is postgresql-7.1.3-2.  I get:
>>
>>          at org.postgresql.jdbc2.ResultSet.next(ResultSet.java:113)
>>          at marketmanager.database.StockSymbol.list(StockSymbol.java:93)
>>          at
>> marketmanager.datacollection.stocks.YahooCollector.fetchDataFromWeb(Yaho
>> oCollector.java:56)
>>          at
>> marketmanager.datacollection.stocks.YahooCollector.fetchData(YahooCollec
>> tor.java:111)
>>          at
>> marketmanager.datacollection.FetchData.main(FetchData.java:13)
>>
>>    This is a bug for sure.  If there is something wrong I am doing, then
>>
>> it should have been caught by an exception and report to me what I was
>> doing wrong.  My code works with an older version of the postgresql jdbc
>>
>> driver.  And my code is pretty basic.
>>
>>    I could not find on the development website the source of this
>> code.   Anybody can provide a pointer?  May I suggest a direct
>> hyperlink to the code to the development site from the
>> http://jdbc.postgresql.org/?
>>
>>
>> Ciao
>> Hans
>>
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 5: Have you checked our extensive FAQ?
>>
>> http://www.postgresql.org/users-lounge/docs/faq.html
>>
>>
>>
>>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>