基于JavaBean,JSP实现登录并显示分页信息的小系统(5)
} finally {
shutup();
}
return pageCount;
}
public ArrayList getUsersByPage(int PageNow) {
pageCount = pageCount();
ct = new connDB().getConn();
int startRow=(PageNow-1)*pageSize;
ArrayList al = new ArrayList();
try {
st = ct.createStatement();
rs=st.executeQuery("SELECT id,name,grade,batch,password,gxqm FROM `students` LIMIT "+startRow+","+pageSize);
while(rs.next()){
Userbean ub=new Userbean();
ub.setId(rs.getInt(1));
ub.setName(rs.getString(2));
ub.setGrade(rs.getInt(3));
ub.setBatch(rs.getInt(4));
ub.setPassword(rs.getInt(5));
ub.setGxqm(rs.getString(6));
// System.out.println(rs.getString(6));
al.add(ub);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
shutup();
}
return al;
}
public boolean checkUser(String u, String p) {
boolean b = false;
ct = new connDB().getConn();
try {
st = ct.createStatement();
ResultSet rs = st
.executeQuery("select password from students where name='"
+ u + "'");
if (rs.next()) {
// 说明用户名存在
if (rs.getString(1).equals(p)) {
// 密码正确
b = true;
} else {
return false;
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
shutup();
}
return b;
}
public void shutup() {
try {
if (rs != null)
rs.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (st != null)
st.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
if (ct != null)
ct.close();
相关新闻>>
- 发表评论
-
- 最新评论 更多>>