aspose file tools*
The moose likes JDBC and the fly likes problem retrieving data from DB only inside a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem retrieving data from DB only inside a servlet" Watch "problem retrieving data from DB only inside a servlet" New topic
Author

problem retrieving data from DB only inside a servlet

Samer Goussos
Greenhorn

Joined: Jan 04, 2010
Posts: 2
Hi every one, this is my first post here

I have a database problem when using inside a servlet, now what I am doing is running a method inside a servlet to check the user name and password sent from the login page, but when debugging the method and choose to step into ,to get into this method and see what’s going on it failed, but if I skip the method it success !!, I copy the method to a simple consol application to see if I will face the same issue or not , but it works fine inside a consol application, please check my code bellow:


see guys the line :
This is where it failed , and takes me directly to -->


and the strange thing that I add res.next() to the watch and I see that I returns true ,but the if statement failed.

I am using J2SE 6 ,my IDE is NetBean 1.6 ,the webserver is Glassfish V2, and my database is MS Access 2000.

Any ideas ?
And thank you all in advanced
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18564
    
    8

May I ask what "failed" means in this context?

I might also ask why you aren't using a FORWARD_ONLY result set, since that's how you actually use it, and why your code skips over the first user in the result set, and why you do two separate queries instead of a single join query, but those probably aren't related to the specific question you are asking. They are probably worth dealing with, though.
Samer Goussos
Greenhorn

Joined: Jan 04, 2010
Posts: 2
thank you for your quick reply

what i mean about "failed" is that ,for example i have one record in my database, lets say "X" as a user name, and the method "statement.setString(1,username)" will set the username in the quary to "X" ,so i must return "X" in the result set right ? ,yes it's true because in the watch if i add "res.getString(1)" it will return "X", but it failed when i debug it so when i reach that part of code :


i will not be abeal to enter the if statement the breakpoint will go directly to the else statement, and i want to remind you that the code works perfectly in a console application, by copying the same method without any changes.

thank you
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem retrieving data from DB only inside a servlet