Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.journaldev.jsf.dao;
- import java.sql.Connection;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import com.journaldev.jsf.util.DataConnect;
- public class LoginDAO {
- public static boolean validate(String user, String password) {
- Connection con = null;
- PreparedStatement ps = null;
- try {
- con = DataConnect.getConnection();
- ps = con.prepareStatement("Select uname, password from Users where uname = ? and password = ?");
- ps.setString(1, user);
- ps.setString(2, password);
- ResultSet rs = ps.executeQuery();
- if (rs.next()) {
- return true;
- }
- } catch (SQLException ex) {
- System.out.println("Login error -->" + ex.getMessage());
- return false;
- } finally {
- DataConnect.close(con);
- }
- return false;
- }
- }
Add Comment
Please, Sign In to add comment