public List<Aluno> listarTodos() {
   List<Aluno> lista = new ArrayList<Aluno>();
   String sql = "select * from aluno";
   try {
     pstm = con.prepareStatement(sql);
     rs = pstm.executeQuery();
     while (rs.next()) {
       Aluno aluno = new Aluno();
       aluno.setMatricula(rs.getInt("matricula"));
       aluno.setNome(rs.getString("nome"));
       lista.add(aluno);
     }
   } catch (Exception e) {
     System.out.println("erro ao consultar um aluno " + e.getMessage());
   }
   return lista;
 }
  public Aluno getAlunoByMatricula(int matricula) {
    Aluno aluno = null;
    String sql = "select * from aluno where matricula = ?";
    try {
      pstm = con.prepareStatement(sql);

      pstm.setInt(1, matricula);

      rs = pstm.executeQuery();
      while (rs.next()) {
        aluno = new Aluno();
        aluno.setMatricula(rs.getInt("matricula"));
        aluno.setNome(rs.getString("nome"));
      }

    } catch (Exception e) {
      System.out.println("erro ao consultar um aluno " + e.getMessage());
    }

    return aluno;
  }
  public static void atualizar() {
    aluno = daoAluno.getById(1);
    aluno.setNome("João");
    daoAluno.update(aluno);

    curso = daoCurso.getById(1);
    curso.setNome("Letras");
    daoCurso.update(curso);

    professor = daoProfessor.getById(1);
    professor.setNome("Maria");
    daoProfessor.update(professor);

    turma = daoTurma.getById(1);
    turma.setPeriodo("Matutino");
    daoTurma.update(turma);

    matricula = daoMatricula.getById(1);
    matricula.setCodigoMatricula(123);
    daoMatricula.update(matricula);
  }