質問編集履歴
4
SQL文の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,6 +6,102 @@
|
|
6
6
|
|
7
7
|
![イメージ説明](18464490b5eb5de7d04efeed088ec83a.png)
|
8
8
|
|
9
|
+
```SQL
|
10
|
+
|
11
|
+
-- ユーザーの作成・権限付与
|
12
|
+
|
13
|
+
CREATE USER book_user IDENTIFIED BY systemsss;
|
14
|
+
|
15
|
+
GRANT ALL PRIVILEGES TO book_user;
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
-- ジャンル情報テーブルの作成
|
22
|
+
|
23
|
+
CREATE TABLE genre (
|
24
|
+
|
25
|
+
genre_id NUMBER(2) PRIMARY KEY,
|
26
|
+
|
27
|
+
genre_name VARCHAR2(30 CHAR) NOT NULL
|
28
|
+
|
29
|
+
);
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
-- 書籍情報テーブルの作成
|
34
|
+
|
35
|
+
CREATE TABLE book (
|
36
|
+
|
37
|
+
book_id NUMBER(5) PRIMARY KEY,
|
38
|
+
|
39
|
+
book_name VARCHAR2(60 CHAR) NOT NULL,
|
40
|
+
|
41
|
+
author VARCHAR2(30 CHAR) NOT NULL,
|
42
|
+
|
43
|
+
publication_date DATE NOT NULL,
|
44
|
+
|
45
|
+
stock NUMBER(4) NOT NULL,
|
46
|
+
|
47
|
+
genre_id NUMBER(2) NOT NULL REFERENCES genre(genre_id)
|
48
|
+
|
49
|
+
);
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
-- ユーザ情報テーブルの作成
|
54
|
+
|
55
|
+
CREATE TABLE book_user (
|
56
|
+
|
57
|
+
book_user_id NUMBER(5) PRIMARY KEY,
|
58
|
+
|
59
|
+
book_user_name VARCHAR2(30 CHAR) NOT NULL,
|
60
|
+
|
61
|
+
password VARCHAR2(16 CHAR) NOT NULL
|
62
|
+
|
63
|
+
);
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
-- ジャンル情報テーブルへのレコード登録
|
70
|
+
|
71
|
+
INSERT INTO genre VALUES(1, '文学');
|
72
|
+
|
73
|
+
INSERT INTO genre VALUES(2, '経済');
|
74
|
+
|
75
|
+
INSERT INTO genre VALUES(3, '技術');
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
-- 書籍情報テーブルへのレコード登録
|
80
|
+
|
81
|
+
INSERT INTO book VALUES(1, 'よくわかる経済', '山田健介', '2010/11/3', 10, 2);
|
82
|
+
|
83
|
+
INSERT INTO book VALUES(2, '日本文学傑作選', '大原洋子', '1998/3/5', 3, 1);
|
84
|
+
|
85
|
+
INSERT INTO book VALUES(3, '日本経済史2016', '宮本良太', '2016/7/20', 23, 2);
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
-- ユーザ情報テーブルへのレコード登録
|
90
|
+
|
91
|
+
INSERT INTO book_user VALUES(1, '鈴木太郎', 1111);
|
92
|
+
|
93
|
+
INSERT INTO book_user VALUES(2, '渡辺花子', 2222);
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
COMMIT;
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
```
|
104
|
+
|
9
105
|
```servlet
|
10
106
|
|
11
107
|
package jp.co.sss.crud.servlet;
|
3
タイトルの変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
リストから取得した?データが表示されない。
|
1
|
+
リストから取得した?(取得したかどうか分からないので「?」)データが表示されない。
|
test
CHANGED
File without changes
|
2
表示結果の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
+
![イメージ説明](18464490b5eb5de7d04efeed088ec83a.png)
|
8
|
+
|
7
9
|
```servlet
|
8
10
|
|
9
11
|
package jp.co.sss.crud.servlet;
|
1
servletファイルの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -4,6 +4,62 @@
|
|
4
4
|
|
5
5
|
|
6
6
|
|
7
|
+
```servlet
|
8
|
+
|
9
|
+
package jp.co.sss.crud.servlet;
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
import java.io.IOException;
|
14
|
+
|
15
|
+
import java.util.List;
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
import javax.servlet.ServletException;
|
20
|
+
|
21
|
+
import javax.servlet.annotation.WebServlet;
|
22
|
+
|
23
|
+
import javax.servlet.http.HttpServlet;
|
24
|
+
|
25
|
+
import javax.servlet.http.HttpServletRequest;
|
26
|
+
|
27
|
+
import javax.servlet.http.HttpServletResponse;
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
import jp.co.sss.crud.bean.Emp;
|
32
|
+
|
33
|
+
import jp.co.sss.crud.db.EmpDao;
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
/**
|
38
|
+
|
39
|
+
* Servlet implementation class SelectAll
|
40
|
+
|
41
|
+
*/
|
42
|
+
|
43
|
+
@WebServlet("/SelectAll")
|
44
|
+
|
45
|
+
public class SelectAll extends HttpServlet {
|
46
|
+
|
47
|
+
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
48
|
+
|
49
|
+
List<Emp> empList =EmpDao.findAll();
|
50
|
+
|
51
|
+
request.setAttribute("empList", empList);
|
52
|
+
|
53
|
+
request.getRequestDispatcher("/html/list/list.jsp").forward(request, response);
|
54
|
+
|
55
|
+
}
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
```
|
62
|
+
|
7
63
|
```JavaBeans
|
8
64
|
|
9
65
|
package jp.co.sss.crud.bean;
|