Advertisement
Cyril_P

Untitled

May 9th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.97 KB | None | 0 0
  1.  
  2.         JButton create = new JButton("Create Account");
  3.         create.addActionListener(new ActionListener() {
  4.             public void actionPerformed(ActionEvent e) {
  5.                 String nom = Field_nom.getText();
  6.                 String prenom = Field_prenom.getText();
  7.                 String ddn = Field_ddn.getText();
  8.                 String login = Field_login.getText();
  9.                 @SuppressWarnings("deprecation")
  10.                 String mdp = Field_password.getText();
  11.                 //String mdp_conf = Field_password2.getText();
  12.                 String mail = Field_mail.getText();
  13.                
  14.                 Connection con=null;
  15.                
  16.                 java.sql.PreparedStatement ps = null;
  17.                
  18.                 try {
  19.                     Class.forName("com.mysql.jdbc.Driver");
  20.                     con = DriverManager.getConnection("jdbc:mysql://localhost/puissance_quatre", "root", "1234");
  21.                     ps = con.prepareStatement("insert into joueur (nom,prenom,nom_utilisateur,mot_de_passe,adresse_mail,date_naissance) values (?,?,?,?,?,?)");
  22.                     //ps.setInt (1, id_joueur);
  23.                     System.out.println("nom :"+nom+"::");
  24.                     ps.setString(1, nom);
  25.                     ps.setString(2, prenom);
  26.                     ps.setString(3, login);
  27.                     ps.setString(4, mdp);
  28.                     ps.setString(5, mail);
  29.                     ps.setString(6, ddn);
  30.                    
  31.                     int i = ps.executeUpdate();
  32.                     if (i>0){
  33.                      JOptionPane.showMessageDialog(null, "joueur enregistré !!!!");
  34.                     }
  35.                     else {
  36.                         JOptionPane.showMessageDialog(null, "Problème de connexion ! ");
  37.                     }
  38.                    
  39.                 }catch(Exception er) {
  40.                         JOptionPane.showMessageDialog(null, er);
  41.                     }
  42.    
  43.                
  44.             }
  45.         });
  46.        
  47.         create.setBounds(200, 321, 123, 23);
  48.         frame.getContentPane().add(create);
  49.        
  50.         JButton exit = new JButton("Exit");
  51.         exit.addActionListener(new ActionListener(){
  52.             public void actionPerformed(ActionEvent e){
  53.                 new EcranDemarrage();
  54.                 frame.setVisible(false);
  55.                 frame.dispose();
  56.             }
  57.         });
  58.         exit.setBounds(341, 321, 123, 23);
  59.         frame.getContentPane().add(exit);
  60.        
  61.         Field_password = new JPasswordField();
  62.         Field_password.setBounds(235, 160, 180, 20);
  63.         frame.getContentPane().add(Field_password);
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement