Give column a name..
String querys = "SELECT COUNT(*) as count FROM
Reference that column from the ResultSet object into an int and do your logic from there..
PreparedStatement statements = connection.prepareStatement(querys);
statements.setString(1, item.getProductId());
ResultSet resultSet = statements.executeQuery();
while (resultSet.next()) {
    int count = resultSet.getInt("count");
    if (count >= 1) {
        System.out.println("Product ID already exists.");
    } else {
        System.out.println("New Product ID.");
    }
}
Hope this helps!!
To know more about Java, join our Java course online today.
Thank you