Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void consultarAluno()
- {
- try {
- setId(Integer.parseInt(JOptionPane.showInputDialog("Digite o ID do aluno:")));
- Connection conexao = DriverManager.getConnection("jdbc:mysql://localhost/bd_eclipse", "root", "etecjau" );
- PreparedStatement at = conexao.prepareStatement("SELECT * FROM ALUNO WHERE ID= ?");
- at.setInt(1, getId());
- ResultSet rs = at.executeQuery();
- while(rs.next()) {
- JOptionPane.showMessageDialog(null, "Nome: " + rs.getString("NOME") + "\nCurso: " + rs.getString("CURSO"));
- }
- conexao.close();
- }
- catch (Exception e)
- {
- JOptionPane.showMessageDialog(null, "Falha na consulta");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement