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).]
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).]
Joined: Jan 18, 2001
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 :-(
Michael, I am not sure, but that might have something to do with closing connection before extracting data from the ResultSet.
Joined: Jan 18, 2001
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!?
Joined: Apr 05, 2000
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
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?