public void insertStudent(Student student) throws SQLException {
   PreparedStatement stmt = null;
   try {
     stmt =
         con.prepareStatement(
             "INSERT INTO students "
                 + "(firstName, patronymic, surName, sex, dateOfBirth, group_id, educationYear) "
                 + "VALUES (?, ?, ?, ?, ?, ?, ?)");
     stmt.setString(1, student.getFirstName());
     stmt.setString(2, student.getPatronymic());
     stmt.setString(3, student.getSurName());
     stmt.setString(4, new String(new char[] {student.getSex()}));
     stmt.setDate(5, new Date(student.getDateOfBirth().getTime()));
     stmt.setInt(6, student.getGroupId());
     stmt.setInt(7, student.getEducationYear());
     stmt.execute();
   } finally {
     if (stmt != null) {
       stmt.close();
     }
   }
 }
 public void updateStudent(Student student) throws SQLException {
   PreparedStatement stmt = null;
   try {
     stmt =
         con.prepareStatement(
             "UPDATE students SET "
                 + "firstName=?, patronymic=?, surName=?, "
                 + "sex=?, dateOfBirth=?, group_id=?, educationYear=?"
                 + "WHERE student_id=?");
     stmt.setString(1, student.getFirstName());
     stmt.setString(2, student.getPatronymic());
     stmt.setString(3, student.getSurName());
     stmt.setString(4, new String(new char[] {student.getSex()}));
     stmt.setDate(5, new Date(student.getDateOfBirth().getTime()));
     stmt.setInt(6, student.getGroupId());
     stmt.setInt(7, student.getEducationYear());
     stmt.setInt(8, student.getStudentId());
     stmt.execute();
   } finally {
     if (stmt != null) {
       stmt.close();
     }
   }
 }