File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes query problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "query problem" Watch "query problem" New topic

query problem

Bill Brasskey
Ranch Hand

Joined: Jun 01, 2004
Posts: 47
In my jsp, I'm trying to pull data from a MS SqlServer 2000 db.I have a panelists table and a survey table. Panelists primary=record_id, which relates to panelist_id in the survey table. I want to pull data for panelists who have yet to complete a survey(i.e. panelists.record_id != surveys.panelist_id). I'm getting a null pointer exception. When I do a query for panelists who have completed a survey(i.e. panelist.record_id=surveys.panelist_id), the dataset comes back fine.
I'm new to programming, and I realize this doesn't relate too much to jdbc, but any advice will be greatly appreciated.
[ June 28, 2004: Message edited by: Bill Brasskey ]
Sadanand Murthy
Ranch Hand

Joined: Nov 26, 2003
Posts: 382
Not knowing how you have written your sql & your jsp makes it rather difficult to determine the cause of the NPE. Look at the stack trace; it will tell you which line of code generated the NPE. Then look at that line # in the .java file that would have been generated from your jsp and try to determine the reason for the NPE.

Are you using a minus query to get the appropriate result set?
select col1, ... from table 1
minus select col2, ... from table 2

Or you can use something like this:
select col1,... from table 1 where id not in (select id from table 2)

Ever Existing, Ever Conscious, Ever-new Bliss
I agree. Here's the link:
subject: query problem
It's not a secret anymore!