Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Hi, i am logging in using usernam

Status
Not open for further replies.

technohead

Technical User
Jan 12, 2002
64
0
0
US
Hi,
i am logging in using username and password. I want to validate this so that what is in the database is equal to what was entered into the login fields. below is the select statement i used to get the info from the database. how do i use a .equals to compare whats in the database to what was typed in.

Thanks




class GSTSLoginHelper
{
GSTSDBConnection conn = new GSTSDBConnection();
conn.getConnection();

public void validate(String CustomerName, String CustomerPwd)
{
String sql = ("Select ut_userType from userTable where ut_userName = '"+CustomerName+"' and ut_password = '"+CustomerPwd+"'");
Statement stat = con.createStatement();
ResultSet rs = stat.executeQuery(sql);
while(rs.next)
{
ut_userType = rs.getString("ut_userType");
System.out.println(rs.getString("ut_userType");
}
}
}
 
Well, as you are passing the username and password to the database in your SQL statement, then if it returns with some data, then you know already that they match - the statement would return null if not ...

However, to use the String.equals() method, would be :
Code:
if (StingOne.equals(StringTwo)) {
          //do some stuff
      }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top