public void run() {
    
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        
        String result;
        while (true) {
            try {
                //Reading data from client
                String userLogin = br.readLine();
                String userPassword = br.readLine();
                if ((userLogin.length() != 0) && (userPassword.length() != 0)) {
                    try {
                    
                        UsersDAO users = new UsersDAO();
                        //Check for user login
                        if (users.checkLogin(userLogin)) {
                            Users user = new Users();
                            
                            user.setUserName(userLogin);
                            user.setUserPsw(userPassword);
                            user.setUserState(RegForm.userDefaultState);
                            user.setUserTypeId(RegForm.userDefaultType);
                            
                            users.add(user);                            
                            result = regOk;
                            break;
                        } else {
                            result = loginFail;
                            break;
                        }
                    } catch (SQLException ex) {                    
                        result = regFail;
                        break;
                    }
                } else {                    
                    result = wrongInput;
                    break;
                }

            } catch (IOException ex) {
                result = regFail;
                break;
            }
        }
        // Send response to client
        PrintWriter pw = new PrintWriter(os, true);
        pw.println(result);
        try {
            is.close();
            os.close();
            socket.close();
        } catch (IOException ex) {
            System.out.println("Ошибка закрытия соединения!");
        }
    }