質問編集履歴

2

ファイルの追加

2020/04/10 12:54

投稿

NodaYudai
NodaYudai

スコア8

test CHANGED
File without changes
test CHANGED
@@ -106,29 +106,7 @@
106
106
 
107
107
  at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
108
108
 
109
- at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
110
-
111
- at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
112
-
113
- at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
114
-
115
- at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:367) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
116
-
117
- at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
118
-
119
- at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
120
-
121
- at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1639) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
122
-
123
- at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
124
-
125
- at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
126
-
127
- at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
128
-
129
- at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.31.jar:9.0.31]
130
-
131
- at java.base/java.lang.Thread.run(Thread.java:834) ~[na:na]
109
+ <後略>
132
110
 
133
111
  ```
134
112
 
@@ -210,6 +188,70 @@
210
188
 
211
189
  ```
212
190
 
191
+ ```java
192
+
193
+ Hello.Repository
194
+
195
+
196
+
197
+ package com.example.demo.trySpring;
198
+
199
+
200
+
201
+ import java.util.Map;
202
+
203
+ import org.springframework.beans.factory.annotation.Autowired;
204
+
205
+ import org.springframework.jdbc.core.JdbcTemplate;
206
+
207
+ import org.springframework.stereotype.Repository;
208
+
209
+
210
+
211
+
212
+
213
+ @Repository
214
+
215
+ public class HelloRepository {
216
+
217
+ @Autowired
218
+
219
+
220
+
221
+ private JdbcTemplate jdbcTemplate;
222
+
223
+
224
+
225
+ public Map<String, Object> findOne(int id) {
226
+
227
+ String query = "SELECT "
228
+
229
+ + " user_id, "
230
+
231
+ + " user_name, "
232
+
233
+ + " age "
234
+
235
+ + " FROM m_user "
236
+
237
+ + " WHERE user_id = ? ";
238
+
239
+ Map<String, Object> m_user = jdbcTemplate.queryForMap(query, id);
240
+
241
+
242
+
243
+ return m_user;
244
+
245
+ }
246
+
247
+ }
248
+
249
+
250
+
251
+ ```
252
+
253
+
254
+
213
255
  ```mysql
214
256
 
215
257
  mysql> use user

1

ファイル名の追加

2020/04/10 12:54

投稿

NodaYudai
NodaYudai

スコア8

test CHANGED
File without changes
test CHANGED
@@ -138,7 +138,9 @@
138
138
 
139
139
  ```Java
140
140
 
141
- [一部抜粋]
141
+ [一部抜粋] HelloService.java
142
+
143
+
142
144
 
143
145
  public User findOne(int id) {
144
146
 
@@ -176,6 +178,10 @@
176
178
 
177
179
  ```java
178
180
 
181
+ [一部抜粋] HelloController.java
182
+
183
+
184
+
179
185
  @PostMapping("/hello/db")
180
186
 
181
187
  public String postDbRequest(@RequestParam("text2") String str, Model model) {