基于JavaBean,JSP实现登录并显示分页信息的小系统(4)
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public int getBatch() {
return batch;
}
public void setBatch(int batch) {
this.batch = batch;
}
public int getPassword() {
return password;
}
public void setPassword(int password) {
this.password = password;
}
public String getGxqm() {
return gxqm;
}
public void setGxqm(String gxqm) {
this.gxqm = gxqm;
}
}
connDB.java实现数据库的连接//得到数据库的连接
//得到数据库的连接
package com.ly.model;
import java.sql.*;
import java.util.*;
public class connDB {
private Connection ct=null;
public Connection getConn(){
try {
Class.forName("com.mysql.jdbc.Driver");
ct=DriverManager.getConnection("jdbc:mysql://localhost:3306/collage", "root", "");
} catch (Exception e) {
e.printStackTrace();
}
return ct;
}
}
UserbeanCl.java实现业务逻辑的处理
//这是一个处理类,主要封装对User表的各种操作,包括增删改查
package com.ly.model;
import java.sql.*;
import java.util.ArrayList;
public class UserbeanCl {
private Statement st = null;
private ResultSet rs = null;
private Connection ct = null;
private int pageSize = 10;
private int rowCount = 0;
private int pageCount = 0;
// 验证用户是否存在
public int pageCount() {
try {
// 得到连接
ct = new connDB().getConn();
st=ct.createStatement();
rs = st.executeQuery("select count(*) from students");
//
if(rs.next()){
rowCount=rs.getInt(1);
}
if(rowCount%pageSize==0){
pageCount=rowCount/pageSize;
}else{
pageCount=rowCount/pageSize+1;
}
} catch (Exception e) {
e.printStackTrace();
相关新闻>>
- 发表评论
-
- 最新评论 更多>>