-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;
}
你認爲用戶名是當你執行的where子句中尋找您的查詢? – csmckelvey
錯誤消息是[優秀的搜索關鍵字](https://stackoverflow.com/search?q=No+value+specified+for+parameter+1)。不要不尊重和錯別字。 – BalusC