Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int nameAvailable(MyUserApp app, String name) throws SQLException{
- String sql = "SELECT * FROM user n WHERE username = '"+ name +"';";
- Statement st = app.getCon().createStatement();
- ResultSet rs = st.executeQuery(sql);
- int numResults = rs.getFetchSize();
- return numResults;
- }
- private void RegisterButtonActionPerformed(java.awt.event.ActionEvent evt) {
- String username, password, address, dob;
- boolean status;
- String u;
- try {
- username = newUsernameField.getText();
- password = passwordField2.getText();
- address = addressField.getText();
- dob = dateofbField.getText();
- int no= 5;
- if( username.isEmpty() || password.isEmpty() || password.length() < 6 ){
- jLabel6.setText("The information you typed in is not valid. ");
- status = false;
- showTableDB.setText(""+status);
- }
- else{
- no = this.app.nameAvailable(app, username);
- jLabel6.setText(no+"");
- if(no == 0){
- jLabel6.setText("Registered your account, "+username+"!" + no);
- status = this.app.registerUser(app, username, password, dob, address);
- u = this.app.showInfo(app, username);
- showTableDB.setText(u);
- no = this.app.nameAvailable(app, username);
- }
- else{
- showTableDB.setText("That username is token. Please choose a different one.");
- }
- }
- } catch (SQLException ex) {
- Logger.getLogger(UserAppUI.class.getName()).log(Level.SEVERE, null, ex);
- } catch (InterruptedException ex) {
- Logger.getLogger(UserAppUI.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement