home.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%--
<jsp:include page=""></jsp:include> 액션 태그
--%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>home</title>
<style>
a{text-decoration-line:none;}
header{background: darkblue;color: white; font-weight:bold;
margin-left: 10px; text-align: center;}
nav{background: lightblue;color: white; margin-left: 10px;padding-top: 5px;}
footer{background: blue;color: white;margin-left: 10px; text-align: center; padding-top: 10px;
padding-bottom: 5px;}
</style>
</head>
<body>
<header>여행 예약 프로그램 ver2018-12</header>
<nav>
<jsp:include page="mainmenu.jsp"></jsp:include>
</nav>
<section>
<h3>여행 예약 프로그램 조회</h3>
<img src="../images/under_construction.png">
</section>
<footer>
HRDKOREA Copyright© 2018 All rights reserved.
Human Resources Development Service of Korea
</footer>
</body>
</html>
공통 코드 파일을 import해서 사용
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<a href="travelBook.jsp">예약등록</a>
<a href="travelList.jsp">예약조회</a>
<a href="home.jsp">홈으로</a>
입력 폼 작성
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%--
<jsp:include page=""></jsp:include> 액션 태그
--%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>travelBook</title>
<style>
a{text-decoration-line:none;}
header{background: darkblue;color: white; font-weight:bold;
margin-left: 10px; text-align: center;}
nav{background: lightblue;color: white; margin-left: 10px;padding-top: 5px;}
footer{background: blue;color: white;margin-left: 10px; text-align: center; padding-top: 10px;
padding-bottom: 5px;}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script>
/*유효성 검사
예약번호 글자 ->8
상품코드를 선택 했는지
주민번호가 숫자형인지 6 7
예약자 전화가 숫자형인지 3 4 4
고객이메일에 @문자가 있는지
*/
function validate() {
let rno =document.getElementById("rno").value;
rno=rno.trim();
if(rno.length!=8){
alert("예약번호 8글자 입력")
document.getElementById("rno").focus;
return false;
}
let tcode=document.getElementById("tcode").value;
tcode=tcode.trim();
if(tcode.length==0){
alert("상품코드 선택하세요");
return false;
}
let rjumin1=document.getElementById("rjumin1").value;
rjumin1=rjumin1.trim();
if(rjumin1.length!=6 || isNaN(rjumin1)){
alert("주민번호는 6자리 숫자를 입력해주세요");
document.getElementById("rjumin1").focus;
return false;
}
let rjumin2=document.getElementById("rjumin2").value;
rjumin2=rjumin2.trim();
if(rjumin2.length!=7 || isNaN(rjumin2)){
alert("주민번호는 7자리 숫자를 입력해주세요");
document.getElementById("rjumin2").focus;
return false;
}
let rphone1=document.getElementById("rphone1").value;
rphone1=rphone1.trim();
if (rphone1.length!=3 || isNaN(rphone1)) {
alert("전화번호 3자리를 입력해 주세요");
document.getElementById("rphone1").focus;
return false;
}
let rphone2=document.getElementById("rphone2").value;
rphone2=rphone2.trim();
if (rphone2.length!=4 || isNaN(rphone2)) {
alert("전화번호 4자리를 입력해 주세요");
document.getElementById("rphone2").focus;
return false;
}
let rphone3=document.getElementById("rphone3").value;
rphone3=rphone3.trim();
if (rphone3.length!=4 || isNaN(rphone3)) {
alert("전화번호 4자리를 입력해 주세요");
document.getElementById("rphone3").focus;
return false;
}
let remail=document.getElementById("remail").value;
remail=remail.trim();
if(remail.indexOf("@")==-1){
alert("@문자를 포함해 주세요");
document.getElementById("remail").focus;
return false;
}
return true;
//서버로 전송
}
</script>
</head>
<body>
<header>여행 예약 프로그램 ver2018-12</header>
<nav>
<jsp:include page="mainmenu.jsp"></jsp:include>
</nav>
<section>
<h3>예약 등록하기</h3>
<form name="travelfrm" id="travelfrm" method="post" action="travelBookProc.jsp" onsubmit="return validate()">
<table border="1" class="table">
<tr>
<th class="active">예약번호</th>
<td><input type="text" name="rno" id="rno" size="8" maxlength="8" required autofocus> </td>
</tr>
<tr>
<th class="active">상품코드</th>
<td><select name="tcode" id="tcode">
<option value="">상품선택</option>
<%
Connection con=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
try{
String url="jdbc:oracle:thin:@localhost:1521:xe";
String user="system";
String password="1234";
String driver ="oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
con= DriverManager.getConnection(url, user, password);
StringBuilder sql=new StringBuilder();
sql.append(" select tcode, tarea, tdate ");
sql.append(" from tbl_tourcode_02 ");
sql.append(" order by tcode ");
pstmt=con.prepareStatement(sql.toString());
rs=pstmt.executeQuery();
if(rs.next()){
String tname="";
do{
tname += "<option value='" + rs.getString("tcode") + "'>";
tname += "[" + rs.getString("tcode")+ "]";
tname += rs.getString("tarea");
tname += rs.getString("tdate").substring(0,4)+"-";
tname += rs.getString("tdate").substring(4,6)+"-";
tname += rs.getString("tdate").substring(6);
tname += " 출발";
tname += "</option>";
}while(rs.next());
out.print(tname);
}
}catch(Exception e){
out.println("오라클 연결 실패"+e);
}finally{
try{
if(rs!=null){
rs.close();
}
}catch(Exception e){}
try{
if(pstmt!=null){
pstmt.close();
}
}catch(Exception e){}
try{
if(con!=null){
con.close();}
}catch(Exception e){}
}
%>
</select> </td>
</tr>
<tr>
<th class="active">주민번호</th>
<td><input type="number" name="rjumin1" id="rjumin1" size="6" maxlength="6" required>
- <input type="number" name="rjumin2" id="rjumin2" size="7" maxlength="7" required> </td>
</tr>
<tr>
<th class="active">예약자 성명</th>
<td><input type="text" name="rname" id="rname" size="20" maxlength="20" required> </td>
</tr>
<tr>
<th class="active">예약자 전화</th>
<td><input type="text" name="rphone1" id="rphone1" size="3" maxlength="3" required>
<input type="text" name="rphone2" id="rphone2" size="4" maxlength="4" required>
<input type="text" name="rphone3" id="rphone3" size="4" maxlength="4" required> </td>
</tr>
<tr>
<th class="active">고객 이메일</th>
<td><input type="text" name="remail" id="remail" size="30" maxlength="30" required> </td>
</tr>
<tr>
<th class="active">결제상태</th>
<td><input type="radio" name="rstat" id="rstat" value="1" checked>미납
<input type="radio" name="rstat" id="rstat" value="2">완납
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" class="btn btn-success" value="예약">
<input type="reset" class="btn btn-warning" value="다시쓰기">
</td>
</tr>
</table>
</form>
</section>
<footer>
HRDKOREA Copyright© 2018 All rights reserved.
Human Resources Development Service of Korea
</footer>
</body>
</html>
travelBookProc.jsp -insert
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>travelBookProc</title>
</head>
<body>
<%
//한글 인코딩
request.setCharacterEncoding("UTF-8");
String rno=request.getParameter("rno").trim();
String tcode=request.getParameter("tcode").trim();
String rjumin=request.getParameter("rjumin1").trim()+request.getParameter("rjumin2").trim();
String rname=request.getParameter("rname").trim();
String rphone1=request.getParameter("rphone1").trim();
String rphone2=request.getParameter("rphone2").trim();
String rphone3=request.getParameter("rphone3").trim();
String remail=request.getParameter("remail").trim();
String rstat=request.getParameter("rstat").trim();
Connection con=null;
PreparedStatement pstmt=null;
try{
String url="jdbc:oracle:thin:@localhost:1521:xe";
String user="system";
String password="1234";
String driver ="oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
con= DriverManager.getConnection(url, user, password);
StringBuilder sql=new StringBuilder();
sql.append(" insert into tbl_reserve_01(rno,rjumin,rname,rphone1,rphone2,rphone3,remail,rstat,tcode) ");
sql.append(" values(?,?,?,?,?,?,?,?,?)");
pstmt=con.prepareStatement(sql.toString());
pstmt.setString(1,rno);
pstmt.setString(2, rjumin);
pstmt.setString(3, rname);
pstmt.setString(4, rphone1);
pstmt.setString(5, rphone2);
pstmt.setString(6, rphone3);
pstmt.setString(7, remail);
pstmt.setString(8, rstat);
pstmt.setString(9, tcode);
int cnt=pstmt.executeUpdate();
if(cnt==0){
out.println("<p>예약 실패</p>");
out.println("<p><a href='javascript:history.back()'>재시도</a></p>");
}else{
out.println("<script>");
out.println(" alert('예약 성공');");
out.println(" location.href='travelList.jsp';"); //목록페이지 이동
out.println("</script>");
}
}catch(Exception e){
out.println("오라클 연결 실패"+e);
}finally{
try{
if(pstmt!=null){
pstmt.close();
}
}catch(Exception e){}
try{
if(con!=null){
con.close();}
}catch(Exception e){}
}
%>
</body>
</html>
tavelBookList.jsp
<%@page import="java.text.DecimalFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%--
<jsp:include page=""></jsp:include> 액션 태그
--%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>travelList</title>
<style>
a{text-decoration-line:none;}
header{background: darkblue;color: white; font-weight:bold;
text-align: center;
height:50px;
font-size: 18pt;}
nav{background: lightblue;color: white;padding-top: 5px;}
footer{background: blue;color: white; text-align: center;
padding-top: 10px;
padding-bottom: 5px;}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<header>여행 예약 프로그램 ver2018-12</header>
<nav>
<jsp:include page="mainmenu.jsp"></jsp:include>
</nav>
<section>
<h3>여행 예약 프로그램 조회</h3>
<table class="table">
<tr class="info" >
<th>예약번호</th>
<th>주민번호</th>
<th>성명</th>
<th>성별</th>
<th>전화번호</th>
<th>여행상품</th>
<th>입금상태</th>
<th>금액</th>
<th>수정/삭제</th>
</tr>
<%
Connection con=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
try{
String url="jdbc:oracle:thin:@localhost:1521:xe";
String user="system";
String password="1234";
String driver ="oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
con= DriverManager.getConnection(url, user, password);
StringBuilder sql=new StringBuilder();
sql.append(" select tbl_reserve_01.tcode,tarea ,tdate,ttime,tday,thotel,tmoney,tair ");
sql.append(" ,rno,rjumin,rname,rphone1,rphone2,rphone3,remail,rstat ");
sql.append(" from tbl_tourcode_02 inner join tbl_reserve_01 ");
sql.append(" on tbl_tourcode_02.tcode = tbl_reserve_01.tcode ");
sql.append(" order by tbl_reserve_01.tcode ");
pstmt=con.prepareStatement(sql.toString());
rs=pstmt.executeQuery();
if(rs.next()){
do{
%>
<tr class="success">
<td><%=rs.getString("rno") %></td>
<td><%=rs.getString("rjumin").substring(0,6) + "-" +rs.getString("rjumin").substring(6) %></td>
<td><%=rs.getString("rname") %></td>
<td>
<%
if(rs.getString("rjumin").substring(6,7).equals("1")){
out.print("여자");
}else{out.print("남자");} %>
</td>
<td><%=rs.getString("rphone1")+"-"+rs.getString("rphone2") +"-"+ rs.getString("rphone3") %></td>
<td><%="[" + rs.getString("tcode")+ "]" + "-"
+rs.getString("tarea") +"-"
+rs.getString("tdate")+ "-"
+rs.getString("ttime")+"-"
+rs.getString("thotel")+"-"
+rs.getString("tair")
%></td>
<td>
<% String rstat=rs.getString("rstat");//상태코드
if(rstat.equals("1")){
out.print("미납");
}else if(rstat.equals("2")){
out.print("완납");
}%></td>
<td><%=String.format("\\%,d", rs.getInt("tmoney")) %></td>
<td>
<input type="button" value="수정" onclick="location.href='travelUpdate.jsp?rno=<%=rs.getString("rno")%>'">
<input type="button" value="삭제" onclick="location.href='travelDel.jsp?rno=<%=rs.getString("rno")%>'">
</td>
</tr>
<%
}while(rs.next());
}else{
out.println("<tr>");
out.println("<td colspan='8'>예약 정보없음</td>");
out.println("</tr>");
}
}catch(Exception e){
out.println("오라클 연결 실패"+e);
}finally{
try{
if(rs!=null){
rs.close();
}
}catch(Exception e){}
try{
if(pstmt!=null){
pstmt.close();
}
}catch(Exception e){}
try{
if(con!=null){
con.close();}
}catch(Exception e){}
}
%>
</table>
</section>
<footer>
HRDKOREA Copyright© 2018 All rights reserved.
Human Resources Development Service of Korea
</footer>
</body>
</html>
travelbookDel.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>bookDel</title>
</head>
<body>
<%
//sno값을 가져옴
String rno= request.getParameter("rno");
Connection con=null;
PreparedStatement pstmt=null;
try{
String url="jdbc:oracle:thin:@localhost:1521:xe";
String user="system";
String password="1234";
String driver ="oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
con= DriverManager.getConnection(url, user, password);
StringBuilder sql=new StringBuilder();
sql.append(" Delete from tbl_reserve_01 ");
sql.append(" where rno=? ");
pstmt=con.prepareStatement(sql.toString());
pstmt.setString(1, rno);
int cnt=pstmt.executeUpdate();
if(cnt==0){
out.println("<p>삭제 실패</p>");
out.println("<p><a href='javascript:history.back()'>다시시도</a></p>");
}else{
out.println("<script>");
out.println(" alert('예약삭제 성공');");
out.println(" location.href='travelList.jsp';"); //목록페이지 이동
out.println("</script>");
}
}catch(Exception e){
out.println("오라클 연결 실패"+e);
}finally{
try{
if(pstmt!=null){
pstmt.close();
}
}catch(Exception e){}
try{
if(con!=null){
con.close();}
}catch(Exception e){}
}
%>
</body>
</html>
travelUpdate.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<title>travelUpdate</title>
<script>
/*유효성 검사
예약번호 글자 ->8
상품코드를 선택 했는지
주민번호가 숫자형인지 6 7
예약자 전화가 숫자형인지 3 4 4
고객이메일에 @문자가 있는지
*/
function validate() {
let rno =document.getElementById("rno").value;
rno=rno.trim();
if(rno.length!=8){
alert("예약번호 8글자 입력")
document.getElementById("rno").focus;
return false;
}
let tcode=document.getElementById("tcode").value;
tcode=tcode.trim();
if(tcode.length==0){
alert("상품코드 선택하세요");
return false;
}
let rjumin1=document.getElementById("rjumin1").value;
rjumin1=rjumin1.trim();
if(rjumin1.length!=6 || isNaN(rjumin1)){
alert("주민번호는 6자리 숫자를 입력해주세요");
document.getElementById("rjumin1").focus;
return false;
}
let rjumin2=document.getElementById("rjumin2").value;
rjumin2=rjumin2.trim();
if(rjumin2.length!=7 || isNaN(rjumin2)){
alert("주민번호는 7자리 숫자를 입력해주세요");
document.getElementById("rjumin2").focus;
return false;
}
let rphone1=document.getElementById("rphone1").value;
rphone1=rphone1.trim();
if (rphone1.length!=3 || isNaN(rphone1)) {
alert("전화번호 3자리를 입력해 주세요");
document.getElementById("rphone1").focus;
return false;
}
let rphone2=document.getElementById("rphone2").value;
rphone2=rphone2.trim();
if (rphone2.length!=4 || isNaN(rphone2)) {
alert("전화번호 4자리를 입력해 주세요");
document.getElementById("rphone2").focus;
return false;
}
let rphone3=document.getElementById("rphone3").value;
rphone3=rphone3.trim();
if (rphone3.length!=4 || isNaN(rphone3)) {
alert("전화번호 4자리를 입력해 주세요");
document.getElementById("rphone3").focus;
return false;
}
let remail=document.getElementById("remail").value;
remail=remail.trim();
if(remail.indexOf("@")==-1){
alert("@문자를 포함해 주세요");
document.getElementById("remail").focus;
return false;
}
return true;
//서버로 전송
}
</script>
</head>
<body>
<h3>정보 수정</h3>
<%
//update에서 sno값 받아옴
String rno = request.getParameter("rno");
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
String url = "jdbc:oracle:thin:@localhost:1521:xe";
String user = "system";
String password = "1234";
String driver = "oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
con = DriverManager.getConnection(url, user, password);
StringBuilder sql = new StringBuilder();
//1.수정할 데이터를 먼저 가져온다
sql.append(" SELECT rno, rjumin, rname, rphone1, rphone2, rphone3, remail, rstat, tcode ");
sql.append(" FROM tbl_reserve_01 ");
sql.append(" where rno=? ");
pstmt = con.prepareStatement(sql.toString());
pstmt.setString(1, rno);
rs = pstmt.executeQuery();
if (rs.next()) {
//2.1의 내용을 폼에 출력 sungjukForm 참조
%>
<form action="travelUpdateProc.jsp" name="travelUfrm" id="travelUfrm"
method="post">
<table class="table table-hover">
<tr>
<th class="active">예약번호</th>
<td><input type="text" name="rno" id="rno" size="8"
maxlength="8" value="<%=rs.getString("rno")%>" required autofocus>
</td>
</tr>
<tr>
<th class="active">상품코드</th>
<td>
<%String tcode=rs.getString("tcode"); %>
<select name="tcode" id="tcode">
<option value="">상품선택 </option>
<option value="JJ01" <%if(tcode.equals("JJ01")){out.print("selected");}%>>[JJ01] 제주-20181201</option>
<option value="JJ02" <%if(tcode.equals("JJ02")){out.print("selected");}%>>[JJ02] 부산-20181201</option>
<option value="JJ03" <%if(tcode.equals("JJ03")){out.print("selected");}%>>[JJ03] 제주-20181204</option>
<option value="JJ04" <%if(tcode.equals("JJ04")){out.print("selected");}%>>[JJ04] 제주-20181207</option>
<option value="JJ05" <%if(tcode.equals("JJ05")){out.print("selected");}%>>[JJ05] 부산-20181209</option>
<option value="JJ06" <%if(tcode.equals("JJ06")){out.print("selected");}%>>[JJ06] 제주-20181210</option>
</select>
</td>
</tr>
<tr>
<th class="active">주민번호</th>
<td><input type="number" name="rjumin1" id="rjumin1" size="6"
maxlength="6" value="<%=rs.getString("rjumin").substring(0, 6)%>"
required> - <input type="number" name="rjumin2"
id="rjumin2" size="7" maxlength="7"
value="<%=rs.getString("rjumin").substring(6)%>" required>
</td>
</tr>
<tr>
<th class="active">예약자 성명</th>
<td><input type="text" name="rname" id="rname" size="20"
maxlength="20" value="<%=rs.getString("rname")%>" required>
</td>
</tr>
<tr>
<th class="active">예약자 전화</th>
<td><input type="text" name="rphone1" id="rphone1" size="3"
maxlength="3" value="<%=rs.getString("rphone1")%>" required>
<input type="text" name="rphone2" id="rphone2" size="4"
maxlength="4" value="<%=rs.getString("rphone2")%>" required>
<input type="text" name="rphone3" id="rphone3" size="4"
maxlength="4" value="<%=rs.getString("rphone3")%>" required>
</td>
</tr>
<tr>
<th class="active">예약자 이메일</th>
<td><input type="text" name="remail" id="remail" size="30"
maxlength="30" value="<%=rs.getString("remail")%>" required>
</td>
</tr>
<tr>
<th class="active">결제상태</th>
<td>
<%
String rstat = rs.getString("rstat");
%>
<input type="radio" name="rstat" id="rstat" value="1" <%if(rstat.equals("1")){out.print("checked");}%>>미납
<input type="radio" name="rstat" id="rstat" value="2"<%if (rstat.equals("2")) {out.print("checked");}%>>완납
</td>
</tr>
<tr>
<td colspan="2" align="center"><input class="btn btn-primary"
type="submit" value="수정"> <input class="btn btn-secondary"
type="reset" value="취소"></td>
</tr>
</table>
</form>
<%
} else {
out.println("해당 글 없음");
}
} catch (Exception e) {
out.println("오라클 연결 실패" + e);
} finally {
try {
if (rs != null) {
rs.close();
}
} catch (Exception e) {
}
try {
if (pstmt != null) {
pstmt.close();
}
} catch (Exception e) {
}
try {
if (con != null) {
con.close();
}
} catch (Exception e) {
}
}
%>
</body>
</html>
travleUpdateProc
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.PreparedStatement"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
String rno = request.getParameter("rno");
request.setCharacterEncoding("UTF-8");
String rname=request.getParameter("rname").trim();
String rjumin1=request.getParameter("rjumin1").trim();
String rjumin2=request.getParameter("rjumin2").trim();
String rjumin= rjumin1+rjumin2;
String rphone1=request.getParameter("rphone1").trim();
String rphone2=request.getParameter("rphone2").trim();
String rphone3=request.getParameter("rphone3").trim();
String rphone = rphone1+rphone2+rphone3;
String remail =request.getParameter("remail").trim();
String rstat=request.getParameter("rstat").trim();
String tcode=request. getParameter("tcode").trim();
Connection con=null;
PreparedStatement pstmt=null;
try{
String url="jdbc:oracle:thin:@localhost:1521:xe";
String user="system";
String password="1234";
String driver ="oracle.jdbc.driver.OracleDriver";
Class.forName(driver);
con= DriverManager.getConnection(url, user, password);
StringBuilder sql=new StringBuilder();
sql.append(" update tbl_reserve_01 ");
sql.append(" set rname=?,rjumin=?,rphone1=?,rphone2=?,rphone3=?,remail=?,rstat=?,tcode=? ");
sql.append(" where rno=? ");
pstmt= con.prepareStatement(sql.toString());
pstmt.setString(1,rname);
pstmt.setString(2,rjumin);
pstmt.setString(3,rphone1);
pstmt.setString(4,rphone2);
pstmt.setString(5,rphone3);
pstmt.setString(6,remail);
pstmt.setString(7,rstat);
pstmt.setString(8,tcode);
pstmt.setString(9, rno);
int cnt=pstmt.executeUpdate();
if(cnt==0){
out.println("<p>예약 수정 실패</p>");
out.println("<p><a href='javascript:history.back()'>재시도</a></p>");
}else{
out.println("<script>");
out.println(" alert('예약수정 성공');");
out.println(" location.href='travelList.jsp';"); //목록페이지 이동
out.println("</script>");
}
}catch(Exception e){
out.println("오라클 연결 실패"+e);
}finally{
try{
if(pstmt!=null){
pstmt.close();
}
}catch(Exception e){}
try{
if(con!=null){
con.close();}
}catch(Exception e){}
}
%>
</body>
</html>