| Author |
Problem with resultset or query?
|
Rajkumar balakrishnan
Ranch Hand
Joined: May 29, 2008
Posts: 445
|
|
I used the below code to find the number of entries in my database, but it fails to work... Please help me whats the problem here with my code..
: Code Edited :
|
Never try to be a hard-worker. Be a smart-worker.
My Blog
|
 |
Shailesh Chandra
Ranch Hand
Joined: Aug 13, 2004
Posts: 1076
|
|
I do not think that you have provided actual code. Also It is bad practice to put jdbc code in JSPs Could you please tell us following. 1.Where is connection in your code ? I guess db.connect() returns a connection 2.Where are you creating statement. 3. did you check log / console for output of System.out.println(e); Use the following catch block, It will put stacktrace on jsp. Shailesh [ November 03, 2008: Message edited by: Shailesh Chandra ]
|
Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
Here's the code which is throwing the exception: First you set the variable ps to null. You don't have any code which assigns anything else to it, and then you try to call its executeQuery method. So you get a NullPointerException. You shouldn't be putting this sort of code in a JSP. And you shouldn't be using a JSP as a test harness for the code either, because (as you can see) you don't get to see the exceptions properly. So stop doing that. Just write some plain old Java code to test your database accessing. Once you have it working, then put it back into a web application. (But preferably not into a JSP. Putting database code in a JSP hasn't been a best practice for several years now.)
|
 |
 |
|
|
subject: Problem with resultset or query?
|
|
|