3段階目終了
This commit is contained in:
@@ -76,4 +76,29 @@ public class EmployeeDAO {
|
|||||||
return rtnList;
|
return rtnList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//社員テーブルから指定された社員IDに一致するデータを取得し、DTOに設定の上、リスト形式で戻
|
||||||
|
public List<EmployeeDTO> selectById(int id_employee) throws SQLException {
|
||||||
|
List<EmployeeDTO> list = new ArrayList<>();
|
||||||
|
String sql = "SELECT * FROM employee WHERE ID_EMPLOYEE = ?";
|
||||||
|
try {
|
||||||
|
|
||||||
|
this.stmt = con.prepareStatement(sql.toString());
|
||||||
|
this.stmt.setInt(1, id_employee);
|
||||||
|
this.rs = this.stmt.executeQuery();
|
||||||
|
while (rs.next()) {
|
||||||
|
EmployeeDTO dto = new EmployeeDTO();
|
||||||
|
dto.setID_EMPLOYEE(rs.getInt("ID_EMPLOYEE"));
|
||||||
|
dto.setNM_EMPLOYEE(rs.getString("NM_EMPLOYEE"));
|
||||||
|
dto.setKN_EMPLOYEE(rs.getString("KN_EMPLOYEE"));
|
||||||
|
dto.setMAIL_ADDRESS(rs.getString("MAIL_ADDRESS"));
|
||||||
|
dto.setPASSWORD(rs.getString("PASSWORD"));
|
||||||
|
dto.setID_DEPARTMENT(rs.getInt("ID_DEPARTMENT"));
|
||||||
|
list.add(dto);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
DbUtil.closeStatement(this.stmt);
|
||||||
|
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ public class Main {
|
|||||||
case "1":
|
case "1":
|
||||||
empList = empDao.selectAll();
|
empList = empDao.selectAll();
|
||||||
break;
|
break;
|
||||||
|
case "2":
|
||||||
|
String inputId = inputCheck("検索する社員ID", true);
|
||||||
|
int input = Integer.parseInt(inputId);
|
||||||
|
empList = empDao.selectById(input);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user