Salve ragazzi vi mostro 2 query....molto simili
la prima funziona e la seconda no....potreste aiutarmi a capire???
codice:
public boolean login() {
        auth = false;
        try {
            ResultSet r1 = s.executeQuery("SELECT * FROM admin WHERE username='" + getUsername() + "' and password= '" + getPassword() + "'");
            if (r1.next()) {
                username = r1.getString("username");
                password = r1.getString("password");
                nome = r1.getString("nome");
                cognome = r1.getString("cognome");
                auth = true; //se l'utente esiste nel database
            }
            else {
                ResultSet r2 = s.executeQuery("SELECT * FROM utentipri WHERE username='" + getUsername() + "' and password= '" + getPassword() + "'");
                if (r2.next()) {
                    username = r2.getString("username");
                    password = r2.getString("password");
                    nome = r2.getString("nome");
                    cognome = r2.getString("cognome");
                    auth = true; //se l'utente esiste nel database
                }
                ResultSet r3 = s.executeQuery("SELECT * FROM visitatori WHERE username='" + getUsername() + "' and password= '" + getPassword() + "'");
                if (r3.next()) {
                    username = r3.getString("username");
                    password = r3.getString("password");
                    nome = r3.getString("nome");
                    cognome = r3.getString("cognome");
                    auth = true; //se l'utente esiste nel database
                }
            }
        }
        catch (Exception e) {
            msgErrore = e.getMessage();
        }
        return auth;
    }
codice:
public boolean RecuperoPass() 
    {
        recupero=false;
        try 
        {
            ResultSet r1 = s.executeQuery("UPDATE admin SET password = '" + getPassword() + "' WHERE email = '" + getEmail() + "'");
            if(r1.next()) 
            {
                password = r1.getString("password");
                email = r1.getString("email");
                recupero=true; //se la password è stata modificata
            }
            else 
            {
                ResultSet r2 = s.executeQuery("UPDATE utentipri SET password = '" + getPassword() + "' WHERE email = '" + getEmail() + "'");
                if (r2.next()) 
                {
                    password = r2.getString("password");
                    email = r2.getString("email");
                    recupero=true; //se la password è stata modificata
                }
                ResultSet r3 = s.executeQuery("UPDATE visitatori SET password = '" + getPassword() + "' WHERE email = '" + getEmail() + "'");
                if (r3.next()) 
                {
                    password = r3.getString("password");
                    email = r3.getString("email");
                    recupero=true; //se la password è stata modificata
                }
            }
        }
        catch(Exception e) 
        {
            msgErrore=e.getMessage();
        }
        return recupero;
    }
vi dico in anticipo che il db è mysql....nella jsp ho inserito tutti i system.out possibili e dunque in embrambi i casi i dati vengono passati ed il db è collegato...solo che la seconda query mi restituisce false
ps la 2 query non modifica la password nel database