Advertisement
Guest User

Untitled

a guest
Jul 26th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. public void consultarAluno()
  2. {
  3. try{
  4. setId(Integer.parseInt(JOptionPane.showInputDialog("Digite o ID do Aluno")));
  5. Connection conexao = DriverManager.getConnection("jdbc:mysql://localhost/bd_eclipse", "root", "etecjau");
  6. PreparedStatement st = conexao.prepareStatement("select * from Alunos whwre id=?");
  7. st.setInt(1, getId());
  8. ResultSet rs = st.executeQuery();
  9. while(rs.next())
  10. {
  11. JOptionPane.showMessageDialog(null, "Nome: " + rs.getString("nome") + "\nCurso: " + rs.getString("curso"));
  12. }
  13. conexao.close();
  14. }
  15. catch(Exception e)
  16. {
  17. JOptionPane.showMessageDialog(null, "Falha na Consulta");
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement