質問編集履歴
1
DAOの該当箇所の追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -107,3 +107,51 @@
|
|
107
107
|
テストで問題なく出力されたので文法には間違いがないはず。。。
|
108
108
|
|
109
109
|
なぜサーブレットのdoPostになると結果が違うのかはまってます
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
DAOの該当箇所
|
114
|
+
|
115
|
+
```
|
116
|
+
|
117
|
+
public List<Bean> findAll() {
|
118
|
+
|
119
|
+
List<Bean> list = new ArrayList<>();
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
try (Connection con = DriverManager.getConnection(DBURL, DBUSER, DBPASS)) {
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
String sql = "SELECT * FROM ACCOUNT";
|
128
|
+
|
129
|
+
Statement smt = con.createStatement();
|
130
|
+
|
131
|
+
ResultSet rs = smt.executeQuery(sql);
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
while (rs.next()) {
|
136
|
+
|
137
|
+
String name = rs.getString("NAME");
|
138
|
+
|
139
|
+
String text = rs.getString("TEXT");
|
140
|
+
|
141
|
+
Bean bean = new Bean(name, text);
|
142
|
+
|
143
|
+
list.add(bean);
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
} catch (SQLException e) {
|
148
|
+
|
149
|
+
e.printStackTrace();
|
150
|
+
|
151
|
+
}
|
152
|
+
|
153
|
+
return list;
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
```
|