954,523 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Missing return statement

Hi,
I'm trying to check the login.
The values of id and pw are send from a textbox and the values of userid and password are from a mysql database. I try to compare them and if they are equal i want to return true and else return false. But i always get the missing return statement error.
And if I put my return somewhere else i get the unreachable statement error. Can someone help me?

public Boolean CheckLogin(int id, String pw)
{ // missing return statement error
try
{
int userid = 0;
String password = "";
ResultSet rs = null;
rs = KrijgLogin.executeQuery();
userid = rs.getInt("userid");
password = rs.getString("wachtwoord");
if (userid == id && wachtwoord.equals(pw))
{
return true;
}
else
{
return false;
}
} catch (SQLException ex) {

}
}

klenne
Newbie Poster
5 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

Hi, I'm trying to check the login. The values of id and pw are send from a textbox and the values of userid and password are from a mysql database. I try to compare them and if they are equal i want to return true and else return false. But i always get the missing return statement error. And if I put my return somewhere else i get the unreachable statement error. Can someone help me?

public Boolean CheckLogin(int id, String pw) { // missing return statement error try { int userid = 0; String password = ""; ResultSet rs = null; rs = KrijgLogin.executeQuery(); userid = rs.getInt("userid"); password = rs.getString("wachtwoord"); if (userid == id && wachtwoord.equals(pw)) { return true; } else { return false; } } catch (SQLException ex) { } }

In case there is an error, there is no return from your catch statement...

DVANRIPER
Newbie Poster
1 post since Apr 2009
Reputation Points: 10
Solved Threads: 1
 
catch (SQLException ex) {
return false;
}


Add this and try again. As ur catch exception dont have return thats y u are encountering this error.

Majestics
Practically a Master Poster
621 posts since Jul 2007
Reputation Points: 199
Solved Threads: 49
 

problem solved!
thank you very much!

klenne
Newbie Poster
5 posts since Aug 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: