Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String pede_id=JOptionPane.showInputDialog(null,"Qual o ID a que se quer ligar?");
- try{
- //Registar JDBC driver
- Class.forName("com.mysql.jdbc.Driver");
- //Ligação á BD
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/Chave?zeroDateTimeBehavior=convertToNull", "root", "1234");
- //Executar a query
- Statement stmt = (Statement) conn.createStatement();
- if (chave_cc.equals(pede_id)){ // A chave é a tabela da base de dados
- JOptionPane.showMessageDialog(null,"Ligou-se corretamente","Display Message",JOptionPane.INFORMATION_MESSAGE);
- // servidor s = new servidor();
- // s.setVisible(true);
- cliente c = new cliente();
- c.setVisible(true);
- }
- else{
- JOptionPane.showMessageDialog(null,"Não existe atualmente máquinas com esse ID no servidor");
- }
- }catch(Exception e){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement