View Single Post
Old 01-17-2012, 04:17 PM   PM User | #2
alykins
Senior Coder

 
alykins's Avatar
 
Join Date: Apr 2011
Posts: 1,608
Thanks: 37
Thanked 183 Times in 182 Posts
alykins will become famous soon enough
first I think you should change this-
Code:
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM  `users`");
rs.first();
String username = rs.getString("username");
String password = rs.getString("password");
if (userGiven.equalsIgnoreCase(username) && passGiven.equals(password)) {
        rs.close();
	return true;
	}
else {
	rs.close();
        return false;
	}
the other stuff from my research looks "ok"- i am wondering if the culprit is lying in the breaks as well as the trailing rs.close(). They happen after the return statement and that may be making it fussy. You are sure you have a table named users? Does MySQL have a management studio? (I assume it does) does that query work in your MySQL studio? (ie make sure your query is returning and not bombing)

Edit: The SQL exceptions bother me hence why I said to run query in SQL- But also of concern is it saying that method must return boolean which makes me wonder if it is thinking it is attempting to return something else (could be the exception) also worth noting is that the stack trace has a comment of unreachable code- again my suggestion to alter the code and see if it works.

Edit Edit: also in you connection string code you have hard coded localhost:3306; you are sure that is the port for MySQL? I have not used MySQL before but unless you explicitly tell SQL Server to talk on a spcific port there is no need to call out the port- but that is SQL Server not MySQL.
__________________

I code C hash-tag .Net
Reference: W3C W3CWiki .Net Lib
Validate: html CSS
Debug: Chrome FireFox IE

Last edited by alykins; 01-17-2012 at 04:23 PM..
alykins is offline   Reply With Quote