I'm new student with Java and I'm trying to make an app to see if the username and password do exist so I wrote this code and there in the main class I call this method and see if a = true or false.
i tried putting System.out.print statement in the while loop and it didn't show up which means the while loop doesn't works.
public void checkUserName(String username,String password) throws SQLException, ClassNotFoundException
{
openconnection();
String query ="SELECT * FROM hema.employee";
Statement stm=(Statement) con.createStatement();
ResultSet rs;
rs = stm.executeQuery(query);
while(rs.next()){
String un,pass;
un=rs.getString("UserName");
pass=rs.getString("PassWord");
System.out.println("hi your answer is "+ a);
if(un==username&&pass==password){
System.out.println("if Works");
a=true;
break;
}
}
}