STUN
4 코드 -
(3) 예약하기
0
예약하기 화면
public int insert_reservation(ReservationDTO
reservation) {
예약자 명(reservation_name), 예약자 전화번호
reservation_tel), 예약 인원 수(reservation_number)
가게명(title),예약 날짜(reservation_date) 입력
String sql = "INSERT INTO
(
reservation(user_name, user_tel, number,
store_name, reservation_date) VALUES(?,?,?,?,?)";
try {
PreparedStatement pstmt =
st_UserDAO user = new st_UserDAO();
conn.prepareStatement(sql);
out.println(request.getParameter("title"));
pstmt.setString(1,
ReservationDTO reservDTO = new
reservation.getUser_name());
ReservationDTO(request.getParameter("reservation_name"),
DB에 reservation table에 삽입하기 위한 SQL 문 실행
request.getPar ap ms et t me tr .( s" er te sS et rr vi ant gi (o 2n ,_ tel"),
requ er se ts. eg re vt aP at ri ao mn e. t ge er t( U" sr ee sr e_ rt ve alt (i )o )n ;_ number"),
request.getParameter("title"),
pstmt.setString(3,
request.getParameter("reservation_date"));
reservation.getNumber());
int result = user.insert_reservation(reservDTO);
pstmt.setString(4,
if (result == -1) {
reservation.getStore_name());
PrintWriter script = response.getWriter();
pstmt.setString(5,
script.println("<script>");
reservation.getReservation_date());
script.println("alert('예약 실패')");
If result =-1
script.println("history.back()");
else
script.println (r "e <t / us rc nr i pp ts >t "m )t ;. executeUpdate();
}
}
True
else {
catch(Exception e)
PrintWriter script = response.getWriter();
{
script.println("<script>");
e.printStackTrace();
예약 성공 메시지
오류 메시지
예약 실패!
script.println("alert('예약 성공!!!')");
예약성공!
}
script.println("location.href='../St_Join/main.jsp'");
return -1;
script.println("</script>");
script.close();
}
return;
}
메인화면