質問編集履歴
3
「更新」箇所の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -156,11 +156,9 @@
|
|
156
156
|
|
157
157
|
int id = rs.getInt("id");
|
158
158
|
|
159
|
-
in
|
159
|
+
String name = rs.getString("name");
|
160
160
|
|
161
|
-
int weight = rs.getInt("weight");
|
162
|
-
|
163
|
-
System.out.println("取得結果 -> " + id + ":" +
|
161
|
+
System.out.println("取得結果 -> " + id + ":" + name);
|
164
162
|
|
165
163
|
}else{
|
166
164
|
|
2
「更新」箇所の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -141,3 +141,35 @@
|
|
141
141
|
・"SELECT id, name FROM member";
|
142
142
|
|
143
143
|
→DB Viewで試したところ、正常にSELECTされます。(つまりSQLの構文も問題なし)
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
### 更新
|
148
|
+
|
149
|
+
While文を下記のとおりif文に変更して試す
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
if(rs.next()){
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
int id = rs.getInt("id");
|
158
|
+
|
159
|
+
int height = rs.getInt("height");
|
160
|
+
|
161
|
+
int weight = rs.getInt("weight");
|
162
|
+
|
163
|
+
System.out.println("取得結果 -> " + id + ":" + height + ":" + weight);
|
164
|
+
|
165
|
+
}else{
|
166
|
+
|
167
|
+
System.out.println("else");
|
168
|
+
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
→コンソール:elseが返ります。
|
174
|
+
|
175
|
+
rsの中に何も入っていないということでしょうか。SQL自体は正常に動きます。
|
1
・System.out.println("MySQLに接続できました。"); →ただ流れているだけかもしれない。
test
CHANGED
File without changes
|
test
CHANGED
@@ -134,7 +134,9 @@
|
|
134
134
|
|
135
135
|
・System.out.println("MySQLに接続できました。");
|
136
136
|
|
137
|
-
→実行時、コンソールに表示されています。
|
137
|
+
→実行時、コンソールに表示されています。
|
138
|
+
|
139
|
+
しかし、ただ流れているだけかもしれない。
|
138
140
|
|
139
141
|
・"SELECT id, name FROM member";
|
140
142
|
|