the following code works how ever is always returning false. so can you tell me why? and what i should do to fix it?
public boolean checkUser(String user, String password){
boolean connected = false;
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost/finalprojects", "root", "password");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from users where user ='" + user + "' and password ='" + password +"';");
connected = true;
rs.close();
st.close();
return connected;
}catch(Exception e){
e.printStackTrace();
}
return connected;
}