質問編集履歴

1

ソースコードの追加

2019/06/21 08:33

投稿

nyan_engineer
nyan_engineer

スコア30

test CHANGED
File without changes
test CHANGED
@@ -157,3 +157,167 @@
157
157
 
158
158
 
159
159
  どうかご教授いただければ幸いです。
160
+
161
+
162
+
163
+ ###追記
164
+
165
+ 呼び出し元のソースコードです。
166
+
167
+ ```EmployeeInfoDao
168
+
169
+ public EmployeeInfoDto findDetail(String employee_id) {
170
+
171
+
172
+
173
+ EmployeeInfoDto employeeInfoDto = null;
174
+
175
+ Connection conn = null;
176
+
177
+ PreparedStatement pStmt = null;
178
+
179
+ ResultSet rs = null;
180
+
181
+ int employeeId;
182
+
183
+
184
+
185
+ try {
186
+
187
+
188
+
189
+ employeeId = Integer.parseInt(employee_id);
190
+
191
+
192
+
193
+ Convert cvrt = new Convert();
194
+
195
+ SqlConstants sqlConst = new SqlConstants();
196
+
197
+ Constants strConst = new Constants();
198
+
199
+
200
+
201
+ Class.forName(sqlConst.JDBC_DRIVER);
202
+
203
+ conn = DriverManager.getConnection(sqlConst.DB_CONNECT_URI, sqlConst.USER_NAME, sqlConst.PASSWORD);
204
+
205
+ pStmt = conn.prepareStatement(sqlConst.SEARCH_EMPLOYEE_DETAIL);
206
+
207
+ pStmt.setInt(1, employeeId);
208
+
209
+ rs = pStmt.executeQuery();
210
+
211
+
212
+
213
+ while (rs.next()) {
214
+
215
+
216
+
217
+ employeeInfoDto = new EmployeeInfoDto();
218
+
219
+ employeeInfoDto.setEmployeeId(rs.getString(strConst.EMPLOYEE_ID));
220
+
221
+ employeeInfoDto.setName(rs.getString(strConst.NAME));
222
+
223
+ employeeInfoDto.setNameHiragana(rs.getString(strConst.NAME_HIRAGANA));
224
+
225
+ employeeInfoDto.setBirthday(cvrt.formatDateSlash(rs.getString(strConst.BIRTHDAY)));
226
+
227
+ employeeInfoDto.setSex(rs.getString(strConst.SEX));
228
+
229
+ employeeInfoDto.setMailAddress(rs.getString(strConst.MAIL_ADDRESS));
230
+
231
+ employeeInfoDto.setTelephoneNumber(cvrt.addDash(rs.getString(strConst.TELEPHONE_NUMBER)));
232
+
233
+ employeeInfoDto.setCompanyInfoId(rs.getString(strConst.COMPANY_INFO_ID));
234
+
235
+ employeeInfoDto.setBusinessManager(rs.getString(strConst.BUSINESS_MANAGER));
236
+
237
+ employeeInfoDto.setDepartment(rs.getString(strConst.DEPARTMENT));
238
+
239
+ employeeInfoDto.setCommissioningStatus(rs.getString(strConst.COMMISSIONING_STATUS));
240
+
241
+ employeeInfoDto.setEnterDate(cvrt.formatDateSlash(rs.getString(strConst.ENTER_DATE)));
242
+
243
+ employeeInfoDto.setRetireDate(cvrt.formatDateSlash(rs.getString(strConst.RETIRE_DATE)));
244
+
245
+ employeeInfoDto.setStatus(rs.getString(strConst.STATUS));
246
+
247
+
248
+
249
+ return employeeInfoDto;
250
+
251
+ }
252
+
253
+
254
+
255
+ } catch (SQLException e) {
256
+
257
+ e.printStackTrace();
258
+
259
+
260
+
261
+ return null;
262
+
263
+
264
+
265
+ } catch (ClassNotFoundException e) {
266
+
267
+ e.printStackTrace();
268
+
269
+
270
+
271
+ return null;
272
+
273
+
274
+
275
+ } catch (NumberFormatException e) {
276
+
277
+ e.printStackTrace();
278
+
279
+
280
+
281
+ return null;
282
+
283
+
284
+
285
+ } finally {
286
+
287
+
288
+
289
+ if (conn != null) {
290
+
291
+
292
+
293
+ try {
294
+
295
+
296
+
297
+ conn.close();
298
+
299
+
300
+
301
+ } catch (SQLException e) {
302
+
303
+ e.printStackTrace();
304
+
305
+
306
+
307
+ return null;
308
+
309
+
310
+
311
+ }
312
+
313
+ }
314
+
315
+ }
316
+
317
+ return employeeInfoDto;
318
+
319
+ }
320
+
321
+
322
+
323
+ ```