You haven't checked Whether your result set is empty or not before actually retriving values from Result set...
next() returns true if there is a data in the result set, false it there is not data at the a cursor position
Place your code like this
While(rs.next())
{
pName = rs.getString("productName");
System.out.println("Product: " + pName);
// MATA IN ANTAL
System.out.println("\nEnter amount:");
GroceryStore.amount = GroceryStore.scan.nextInt();
pPrice = rs.getDouble("productPrice");
}