我收到的错误是“参数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;
}
答案 0 :(得分:0)
您需要填写PreparedStatement中的参数
preparedStatement.setLong(1, someIdentifier)