I have a Manager class that saves data in the SQL table and also get result from SQL table and test these data.when I run my program,one frame will be shown that gets ID and pas
The simple answer is that your while loop should terminate when you find a match, so it should read:
while (rst.next() && bool == false) {
if (rst.getString(1).equalsIgnoreCase(userName) && rst.getString(2).equalsIgnoreCase(password)) {
bool = true;
}
}
Note that it would be more efficient to select only rows that match your user id & password, something along the lines of the following: (note that error handling is left as an exercise for the reader)
PreparedStatement stmt;
stmt = conn.prepareStatement("SELECT yahooId , password FROM clienttable WHERE yahooId = ?");
stmt.setString(1, "userName");
ResultSet rst = null;
rst = stmt.executeQuery();
if (rs != null && rs.getString("password").equals(password)) { bool = true; }