Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Null error

 
michael hagberg
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • 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).]
 
Joe Paolangeli
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • 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
  • 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 :-(
 
Michal Harezlak
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Yes, that was it! I was so sure I had the results in the Rs. Many thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic