Advertisement
Guest User

Untitled

a guest
Jun 14th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. String pede_id=JOptionPane.showInputDialog(null,"Qual o ID a que se quer ligar?");
  2.  
  3. try{
  4.  
  5.  
  6. //Registar JDBC driver
  7. Class.forName("com.mysql.jdbc.Driver");
  8. //Ligação á BD
  9.  
  10. Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Chave?zeroDateTimeBehavior=convertToNull", "root", "1234");
  11. //Executar a query
  12. Statement stmt = (Statement) conn.createStatement();
  13. if (chave_cc.equals(pede_id)){ // A chave é a tabela da base de dados
  14. JOptionPane.showMessageDialog(null,"Ligou-se corretamente","Display Message",JOptionPane.INFORMATION_MESSAGE);
  15. // servidor s = new servidor();
  16. // s.setVisible(true);
  17. cliente c = new cliente();
  18. c.setVisible(true);
  19. }
  20. else{
  21. JOptionPane.showMessageDialog(null,"Não existe atualmente máquinas com esse ID no servidor");
  22. }
  23. }catch(Exception e){
  24.  
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement