【发布时间】:2017-08-05 17:42:33
【问题描述】:
我收到错误消息“参数 1 没有特定值”。我想从 UserId 显示登录用户的预订
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 子句中寻找什么用户 ID?
-
错误消息是excellent search keywords。不要不尊重和拼写错误。