• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Null error

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I get a null error every time I try to get a ResultSet back from my Bean. I guess it is because I set my ResultSet to null when I start, but I have to do that or else I get error messages. I get very frustrated over this and would really appreciate help!!
I include the code:
JSP-page:


<%=kategori%>
<%}%>
Bean:

ThanX in advance
[This message has been edited by michael hagberg (edited January 18, 2001).]
 
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What statement is causing the error? Do you have null data in your database?
[This message has been edited by Joe Paolangeli (edited January 18, 2001).]
 
michael hagberg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Im not really sure. The thing is, I use almost exact the same code for updating a table in the db and it works fine. It doesnt return anything (void). But when I try to return a RecordSet (which is the case here) I get a nullpointerexception.
So Ive tried a lot of things in the bean, I even checked the returning ResultSet and it does have values, that is to say it is not null. But somewhere a Null is reported. Im working on it now and to be honest I dont really understand what generates it, I THINK it is something with the ResultSet but... I am not sure :-(
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,
I am not sure, but that might have something to do with closing connection before extracting data from the ResultSet.

 
michael hagberg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
tried that too. Funny thing is, I have one method working, named doInsert. I have that one in the same bean, cant you have that? It is so confusing, cause if I rename the working method to doInsert2 it doesnt work - I get... Null error!
It seems to me that is the same problem, maybe its not the methods? maybe there is something in the architecture that Ive missed!?
 
Joe Paolangeli
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, the closing of the connection is probably causing the null error.
My suggestion would be to process the resultset in the bean. You should define get and set methods for each field that is needed in your jsp. In your JSP you would reference these fields either by JSP property tags or by JSP expressions.
Hope this helps,
Joe
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can't close a connection while a ResultSet is open. Closing the connection will close the ResultSet and set it to null. Remember, the ResultSet is not the actual data from the database, it is the way to get the data. Imagine if you did "select * from a" where a was a table with 10,000,000 rows. Would you really expect the resultSet to contain 10,000,000 rows worth of data?
 
michael hagberg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, that was it! I was so sure I had the results in the Rs. Many thanks!
 
reply
    Bookmark Topic Watch Topic
  • New Topic