Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package cl.cvalpo.dao;
- import cl.cvalpo.conexion.Conexion;
- import cl.cvalpo.entities.Usuario;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- /**
- *
- * @author Esteban Perez
- */
- public class DAOUsuario {
- public Usuario getUsuario(String username, String password) {
- try {
- Conexion conexion = new Conexion();
- Connection conn = conexion.getConexion();
- String sql = "SELECT username, pass FROM login WHERE username = ? AND pass = ?";
- PreparedStatement ps = conn.prepareStatement(sql);
- ps.setString(1, username);
- ps.setString(2, password);
- ResultSet rs = ps.executeQuery();
- Usuario usuario = new Usuario();
- while (rs.next()) {
- usuario.setUsername(rs.getString("username").trim());
- usuario.setPassword(rs.getString("pass").trim());
- }
- conn.close();
- ps.close();
- rs.close();
- return usuario;
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement