LoginDao.java 912 Bytes
Newer Older
Emanuel Lugo committed
1 2 3 4 5 6 7 8
package com.roshka.proyectofinal.login;

import com.roshka.proyectofinal.DataBase;
import com.roshka.proyectofinal.entity.Lenguaje;
import com.roshka.proyectofinal.entity.LoginBean;

import java.sql.Connection;
import java.sql.PreparedStatement;
9
import java.sql.ResultSet;
Emanuel Lugo committed
10 11 12 13

public class LoginDao {

    public boolean validate (LoginBean loginBean) {
14
        boolean status = false;
Emanuel Lugo committed
15 16 17 18
        try {
            Connection con = DataBase.getConnection();

            PreparedStatement ps=con.prepareStatement(
19 20
                    "select * from usuario where correo=? and contrasena = ?");
            ps.setString(1,loginBean.getCorreo());
Emanuel Lugo committed
21
            ps.setString(2, loginBean.getPassword());
22 23
            ResultSet rs = ps.executeQuery();
            status = rs.next();
Emanuel Lugo committed
24 25 26 27 28
            con.close();
        } catch (Exception ex) {
            ex.printStackTrace();
        }

29
            return status ;
Emanuel Lugo committed
30 31 32 33

    }

}