This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Vector from bean to servlet? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Vector from bean to servlet?" Watch "Vector from bean to servlet?" New topic

Vector from bean to servlet?

Ram Luchman

Joined: Mar 30, 2002
Posts: 1
I'm getting nullpointer exception when I pass a resultset turned into vector from a bean to a servlet. I can pass the vector from the bean to a JSP page without problems. My code below. The error happens at this point "rs = (Vector)d.getQueryresult();"
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

One minor point, you shouldn't need to cast (Vector), because the return type of the method is a Vector.

The other thing is when you are building your query, you don't leave a space between the tablename and the WHERE clause.

If you printed the contents of the String 'q', you'd get "SELECT * FROM EmployeesWHERE userID = etc, etc...

Your try-catch-finally in your bean appears to be good, so I'd expect you would find the SQLException stack trace in your log. the 'return v' is in your finally block, so that should be ok.

What about the stack trace you do see? Can you post it?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

wait, it's not in the finally block.

In the bean class, the line that would throw the exception from a malformed query string is:

rs = st.executeQuery(query);

but only after that do you make the new vector.

v = new Vector();

Then below, when you attempt:

v.trimToSize(); This line should throw a NullPointerException
subject: Vector from bean to servlet?
Similar Threads
How to update a database using web forms
Problem with DSN less Connection with MS Access 2000
displat:table tag pls help me
Breaking doXXX methods down into smaller ones
SQL query not giving any result