2017-08-05 66 views
-2

我收到錯誤「沒有參數1的特定值」。我想從用戶ID沒有爲參數1指定值

public ArrayList<booking> viewRestaurantsBooking() throws Exception { 
    System.out.println("In viewRestaurantsBooking!"); 
    ArrayList<booking> myRestaurantsBookingList = new ArrayList<booking>(); 
    try { 
     String selectStatement = "select * from famnection.bookrest where UserId=?"; 
     PreparedStatement prepStmt = con.prepareStatement(selectStatement); 
     ResultSet rs = prepStmt.executeQuery(); 


     while (rs.next()) { 
      System.out.println("Record Found!"); 
      booking myBookings = new booking(); 
      System.out.println("Restaurant Name=" + rs.getString("restName")); 
      myBookings.setRestName(rs.getString("restName")); 
      System.out.println("Booking Date=" + rs.getString("bookingdate")); 
      myBookings.setBookingdate(rs.getDate("bookingdate")); 
      System.out.println("Booking Time=" + rs.getString("bookingtime")); 
      myBookings.setTime(rs.getString("bookingtime")); 
      myRestaurantsBookingList.add(myBookings); 

     } 
    } catch (Exception ex) { 
     throw new Exception("Error:" + ex.getMessage()); 
    } 
    System.out.println("myRestaurantsList SIZE=" + myRestaurantsBookingList.size()); 
    return myRestaurantsBookingList; 
} 
+0

你認爲用戶名是當你執行的where子句中尋找您的查詢? – csmckelvey

+0

錯誤消息是[優秀的搜索關鍵字](https://stackoverflow.com/search?q=No+value+specified+for+parameter+1)。不要不尊重和錯別字。 – BalusC

回答

0

您需要的PreparedStatement填寫參數顯示已登錄用戶的預訂

preparedStatement.setLong(1, someIdentifier) 
相關問題