dao
package com.Test.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.Test.Util.DBUtil;
import com.Test.dto.UsernameDTO;
public class UsernameDAO {
public String findPass(String empPassword){
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
try{
conn = DBUtil.getConnection();
String sql = "select * from Employee where empPassword=? ";
statement = conn.prepareStatement(sql);
statement.setString(2, empPassword);
rs = statement.executeQuery();
if(rs.next()) {
return empPassword;
}
else {
return null;
}
}catch(Exception ee){
ee.printStackTrace();
}
return null;
}
public boolean findUser(String empAccount, String empQuestion,String empAnswer) {
Connection conn = null;
PreparedStatement statement = null;
ResultSet rs = null;
try {
conn = DBUtil.getConnection();
String sql = "select * from Employee where empAccount=? and empQuestion=? and empAnswer=?";
statement = conn.prepareStatement(sql);
statement.setString(1, empAccount);
statement.setString(8, empQuestion);
statement.setString(9, empAnswer);
rs = statement.executeQuery();
if(rs.next()) {
return true;
}
else {
return false;
}
}
catch(Exception e) {
e.printStackTrace();
return false;
}
finally {
try{
rs.close();
statement.close();
conn.close();
}
catch(Exception e1){
e1.printStackTrace();
}
}
}
public boolean findUser(UsernameDTO userdto) {