I'm working on a student database managing program, and am working on the login phase. I query the database for the students id and password and try and match an entry to what the student enters. When a match is found login should be set to true, and it should go to the next page, but for some reason its never passing my if then statement. I'm not entire sure whats wrong,the code for this is below. You'll notice the system.out.println statements, those are there so I can see if it is actually going through the database correctly, and as far as I can tell it does, but login next gets set to true. I would really appreciate any help.
public void actionPerformed(ActionEvent e)
{
//int i;
//String name;
if(e.getSource()==logInButton)
{
String name="";
String password="";
name=inputField.getText();
password=inputField2.getText();
System.out.println(name);
System.out.println(password);
boolean login = false;
try {
connection = DriverManager.getConnection(connectionString, username, pass);
PreparedStatement statement = (PreparedStatement) connection.prepareStatement("SELECT * FROM students");
data = statement.executeQuery();
while(data.next()){
System.out.println(data.getObject("student_id"));
System.out.println(data.getObject("password"));
if (data.getObject("student_id") == name && data.getObject("password") == password){
login = true;
}
}
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if(login == true){
System.out.println("login = true");
logInPanel.setVisible(false);
postLogInPanel.setVisible(true);
}
}