The AccountCheck method is returning false always and saying "Account exists!" always. Idea is to check if there's an existing account in the database and create one if it doesn't. Please help. I am not doing any validations in the code.
private boolean AccountCheck(String username, String password) {
try {
String sql = "select count(*) from user where username=? and password=?";
PreparedStatement pst = conn.prepareStatement(sql);
pst.setString(1, username);
pst.setString(2, password);
ResultSet rs = pst.executeQuery();
if (rs.next()) {
rs.close();
System.out.println("Account exists!");
return false;
} else {
rs.close();
System.out.println("Accout does not exist!");
return true;
}
} catch (SQLException e) {
e.printStackTrace();
return false;
}
}