-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBookCreateResult.jsp
More file actions
78 lines (68 loc) · 3.32 KB
/
BookCreateResult.jsp
File metadata and controls
78 lines (68 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<%@ page contentType="text/html;charset=euc-kr" %>
<%@ page import="java.sql.*" %>
<html>
<head>
<title>도서 등록 결과</title>
</head>
<body>
<%
request.setCharacterEncoding("euc-kr"); // 입력폼에서 전송된 한글데이터 처리
// String 입력폼에서 받는 데이터는 모두 문자열
String bookCtg = request.getParameter("bookCtg");
String bookId = request.getParameter("bookId");
String bookName = request.getParameter("bookName");
String priceParam = request.getParameter("price");
String bookStockParam = request.getParameter("bookStock");
int price = (priceParam != null && !priceParam.isEmpty()) ? Integer.parseInt(priceParam) : 0;
int bookStock = (bookStockParam != null && !bookStockParam.isEmpty()) ? Integer.parseInt(bookStockParam) : 0;
String writer = request.getParameter("writer");
String bookContent = request.getParameter("bookContent");
String publisher = request.getParameter("publisher");
String bookStatus = request.getParameter("bookStatus");
String bookReview = request.getParameter("bookReview");
try {
String DB_URL = "jdbc:mysql://localhost:3306/internetproject";
String DB_ID = "multi";
String DB_PASSWORD = "abcd";
Class.forName("org.gjt.mm.mysql.Driver");
Connection con = DriverManager.getConnection(DB_URL, DB_ID, DB_PASSWORD);
// 수정된 SQL 문
String jsql = "INSERT INTO book(bookCtg, bookId, bookName, price, bookStock, writer, bookContent, publisher,";
jsql= jsql+"bookStatus, bookReview) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
PreparedStatement pstmt = con.prepareStatement(jsql);
pstmt.setString(1, bookCtg);
pstmt.setString(2, bookId);
pstmt.setString(3, bookName);
pstmt.setInt(4, price);
pstmt.setInt(5, bookStock);
pstmt.setString(6, writer);
pstmt.setString(7, bookContent);
pstmt.setString(8, publisher);
pstmt.setString(9, bookStatus);
pstmt.setString(10, bookReview);
pstmt.executeUpdate(); // SQL 문 실행
%>
<center>
<font color="blue" size='6'><b>[ 등록된 도서 정보 ] </b></font><p>
<table border="2" cellpadding="10" style="font-size:10pt;font-family: 맑은 고딕" >
<tr><td width="100">카테고리분류</td><td width="300"><%=bookCtg%></td></tr>
<tr><td width="100">도서 번호</td><td width="300"><%=bookId%></td></tr>
<tr><td width="100">도서 명</td><td width="300"><%=bookName%></td></tr>
<tr><td width="100">도서 가격</td><td width="300"><%=price%> 원</td></tr>
<tr><td width="100">재고수량</td><td width="300"><%=bookStock%> 개</td></tr>
<tr><td width="100">저자</td><td width="300"><%=writer%></td></tr>
<tr><td width="100">상세 설명</td><td width="300"><%=bookContent%></td></tr>
<tr><td width="100">출판사</td><td width="300"><%=publisher%></td></tr>
<tr><td width="100">판매 상태</td><td width="300"><%=bookStatus%></td></tr>
<tr><td width="100">도서 리뷰</td><td width="300"><%=bookReview%></td></tr>
</table><p>
<%
} catch(Exception e) {
out.println(e);
}
%>
<p>
<a href="BookSelect.jsp" style="font-size:10pt;font-family:'맑은 고딕'">전체 등록상품 조회</a><br><br>
</center>
</body>
</html>