public class UserDaoImpl implements IUserDao {
public boolean login(String username, String password) throws SQLException {
Connection con = ConnectionUtil.getConnection();
Statement st = null;
ResultSet rs=null;
boolean loginFlag = false;
try {
String sql = "select * from tb_userinfo where username='"+username+"' and password='"+password+"'";
st=con.createStatement();
rs=st.executeQuery(sql);
while(rs.next()){
loginFlag=true;
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
ConnectionUtil.closeRs(rs);
ConnectionUtil.closeSt(st);
ConnectionUtil.closeCon(con);
}
return loginFlag;
}
public List getCerAddress() throws SQLException {
Connection con=ConnectionUtil.getConnection();
Statement st = null;
ResultSet rs = null;
List ls = new ArrayList();
String regCerAddress = "";
String valCerAddress="";
try{
String sql="select * from tb_ceraddress";
st = con.createStatement();
rs = st.executeQuery(sql);
while(rs.next()){
regCerAddress = rs.getString(1);
valCerAddress = rs.getString(2);
}
ls.add(0, regCerAddress);
ls.add(1,valCerAddress);
}catch(Exception e){
e.printStackTrace();
}finally{
ConnectionUtil.closeRs(rs);
ConnectionUtil.closeSt(st);
ConnectionUtil.closeCon(con);
}
return ls;
}
}