aspose file tools*
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "Simple problem pls help" Watch "Simple problem pls help" New topic
Author

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
Rancher

Joined: Mar 06, 2001
Posts: 13459


Dave.
Pranit Saha
Ranch Hand

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

Joined: Sep 05, 2001
Posts: 139
Just to be on safe side,
always do
if(rs != null && rs.next())
{
//yes;
}
else
{
//no;
}


SCJP2
Pranit Saha
Ranch Hand

Joined: Sep 09, 2001
Posts: 130
Yes deep i've already done this.. thanks for ur quote..
Pranit..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Simple problem pls help
 
Similar Threads
Log On help
Tough authentication question?
handling multiple queries with the same connection
Need to send message to struts JSP after creating PDF
authenticating website users with mysql dbase