wood burning stoves 2.0*
The moose likes Servlets and the fly likes Simple problem pls help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Simple problem pls help" Watch "Simple problem pls help" New topic

Simple problem pls help

Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
I've saved the username and password in a table in sql server. Now the thing is, whenever user logs in. they provide the username and password as usual. and i've a select statement to validate the password as follows.

ResultSet rs = stat.executeQyery("select password from login where username ="+username);
The code gives us the password when the user exist in the table.
But it says "Invalid cursor index" whenever the username is not in table. How can i prevent this error and say "The username doesn't exist please sign-up"..
Thanks in advance.. pls help..
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
Thanks a lot for ur kind help.. it works fine..
Mahesh Rana
Ranch Hand

Joined: Sep 05, 2001
Posts: 139
Just to be on safe side,
always do
if(rs != null && rs.next())

Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
Yes deep i've already done this.. thanks for ur quote..
jQuery in Action, 2nd edition
subject: Simple problem pls help
Similar Threads
Need to send message to struts JSP after creating PDF
Log On help
Tough authentication question?
handling multiple queries with the same connection
authenticating website users with mysql dbase