==================== Problem Description ====================
Process user logins in server-side Servlets I wrote that.
if (Sqlconn.executequery ("SELECT * from User_test" WHERE name = ' "+ username +" ' and password = ' "+ Password +" ' ") = null) {Resp.setcontenttype ("text/xml; Charset=utf-8 "); PrintWriter out = Resp.getwriter () out.print ("User" + Username + "Login Success"); Out.flush (); Out.close ();} else {resp.setcontenttype ("text/xml; Charset=utf-8 "); PrintWriter out = Resp.getwriter (); Out.print ("Username or password is incorrect"); Out.flush (); Out.close ();}
But I found that when I enter the wrong username and password, executeQuery () can still query the value and return to [email protected]. It should be said that the user name and password is incorrect when there should be no return value AH. What's going on? Please advise your predecessors
==================== Solution 1====================
The ExecuteQuery query does not return null anyway, it returns the ResultSet object, so you should determine whether the contents of the ResultSet object are empty.
Android Query Database issues