Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. public int nameAvailable(MyUserApp app, String name) throws SQLException{
  2. String sql = "SELECT * FROM user n WHERE username = '"+ name +"';";
  3. Statement st = app.getCon().createStatement();
  4. ResultSet rs = st.executeQuery(sql);
  5. int numResults = rs.getFetchSize();
  6.  
  7. return numResults;
  8. }
  9.  
  10. private void RegisterButtonActionPerformed(java.awt.event.ActionEvent evt) {
  11. String username, password, address, dob;
  12. boolean status;
  13. String u;
  14. try {
  15.  
  16. username = newUsernameField.getText();
  17. password = passwordField2.getText();
  18. address = addressField.getText();
  19. dob = dateofbField.getText();
  20. int no= 5;
  21.  
  22. if( username.isEmpty() || password.isEmpty() || password.length() < 6 ){
  23. jLabel6.setText("The information you typed in is not valid. ");
  24. status = false;
  25. showTableDB.setText(""+status);
  26. }
  27. else{
  28. no = this.app.nameAvailable(app, username);
  29. jLabel6.setText(no+"");
  30. if(no == 0){
  31. jLabel6.setText("Registered your account, "+username+"!" + no);
  32. status = this.app.registerUser(app, username, password, dob, address);
  33. u = this.app.showInfo(app, username);
  34. showTableDB.setText(u);
  35. no = this.app.nameAvailable(app, username);
  36. }
  37. else{
  38. showTableDB.setText("That username is token. Please choose a different one.");
  39. }
  40.  
  41.  
  42. }
  43.  
  44.  
  45. } catch (SQLException ex) {
  46. Logger.getLogger(UserAppUI.class.getName()).log(Level.SEVERE, null, ex);
  47. } catch (InterruptedException ex) {
  48. Logger.getLogger(UserAppUI.class.getName()).log(Level.SEVERE, null, ex);
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement