public ArrayList<Education> getEducation(String personnelID) { ArrayList<Education> edList = new ArrayList<>(); PreparedStatement ps; ResultSet rs; if (dbc.connect()) { try { String sqlQuery = "select " + EDUCATION_COLUMN + " from " + EDUCATION + " where MaNV = '" + personnelID + "'"; ps = dbc.getConnection().prepareStatement(sqlQuery); rs = ps.executeQuery(); while (rs.next()) { Education ed = new Education(); ed.setKindID(rs.getShort(1)); ed.setGraduationID(rs.getShort(2)); ed.setCourseName(rs.getString(3)); ed.setSchoolName(rs.getString(4)); ed.setFromYear(rs.getShort(5)); ed.setToYear(rs.getShort(6)); ed.setID_IDENTITY(rs.getShort(7)); edList.add(ed); } } catch (SQLException ex) { Logger.getLogger(PersonnelDAO.class.getName()).log(Level.SEVERE, null, ex); } } return edList; }
public boolean insertEducationInfo(String personnelID, Education edu) { boolean check = true; PreparedStatement ps; if (dbc.connect()) { try { String sqlQuery = "INSERT INTO " + EDUCATION + " VALUES(?,?,?,?,?,?,?)"; ps = dbc.getConnection().prepareStatement(sqlQuery); ps.setString(1, personnelID); ps.setShort(2, edu.getKindID()); ps.setShort(3, edu.getGraduationID()); ps.setNString(4, edu.getCourseName()); ps.setNString(5, edu.getSchoolName()); ps.setShort(6, edu.getFromYear()); ps.setShort(7, edu.getToYear()); if (ps.executeUpdate() < 1) { check = false; } } catch (SQLException ex) { Logger.getLogger(PersonnelDAO.class.getName()).log(Level.SEVERE, null, ex); } } return check; }