Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Simple problem pls help

 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave.
 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dave,
Thanks a lot for ur kind help.. it works fine..
Pranit.
 
Mahesh Rana
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to be on safe side,
always do
if(rs != null && rs.next())
{
//yes;
}
else
{
//no;
}
 
Pranit Saha
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes deep i've already done this.. thanks for ur quote..
Pranit..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic