bom gente, o método, o mesmo de um post meu anterior:
public static Professor loginProf(String matricula, String senha)
{
Professor prof = null;
try
{
String sql = "SELECT * FROM professor WHERE matriculaProf = ? AND senha = ?;";
Conexao conex = new Conexao("jdbc:mysql://localhost:3306/mydb",
"com.mysql.jdbc.Driver", "root", "alunolab");
Connection con = conex.obterConexao();
PreparedStatement comando = con.prepareStatement(sql);
comando.setString(1, matricula);
comando.setString(2, senha);
ResultSet resultSet = comando.executeQuery();
while(resultSet.next())
{
prof = new Professor(resultSet.getString("matriculaProf"),
resultSet.getString("senha"));
}
resultSet.close();
comando.close();
con.close();
}catch ( Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
prof = new Professor(matricula, senha);
return prof;
}
Professor prof = ProfessorDAO.loginProf(matricula, senha);
JOptionPane.showMessageDialog(null, "sua senha é: "+ prof.getSenha());
O "prof.getSenha()" me retorna um valor nulo.
Será que eu estou fazendo algo de errado? Alguém pode me ajudar, mais uma vez hoje? hehehehe
Abraços a todos :)