Everything is perfect when I'm logging in. But when I enter an account that doesn't exist, a message dialog loops by the number of account there is in my database. I believe this is because I used while(rss.next()).
Here is my code:
try {
if(e.getSource()==loginButton){
int count = 1;
conn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=login_DB;integratedSecurity=true");
st=conn.createStatement();
rss=st.executeQuery("select * from tblLogin");
while(rss.next()){
String user = rss.getString(1);
String pass = rss.getString(2);
if(usernameTF.getText().equals(user)&&passwordTF.getText().equals(pass)){
JOptionPane.showMessageDialog(null,"YEAAAA");
}//if success
else {
JOptionPane.showMessageDialog(null,"Account doesn't exist! Please try again.");
}
}//while
}//getsource loginButton