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.
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.
Joined: Jan 04, 2010
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.
subject: problem retrieving data from DB only inside a servlet