实体类:
com.zking.entity
package com.zking.entity;
import java.io.Serializable;
/**
* 实体类:书籍类
* @author zjjt
*
*/
public class Book implements Serializable{
private int bid;
private String bname;
private double bprice;
private String btype;
public int getBid() {
return bid;
}
public void setBid(int bid) {
this.bid = bid;
}
public String getBname() {
return bname;
}
public void setBname(String bname) {
this.bname = bname;
}
public double getBprice() {
return bprice;
}
public void setBprice(double bprice) {
this.bprice = bprice;
}
public String getBtype() {
return btype;
}
public void setBtype(String btype) {
this.btype = btype;
}
public Book() {
// TODO Auto-generated constructor stub
}
public Book(int bid, String bname, double bprice, String btype) {
this.bid = bid;
this.bname = bname;
this.bprice = bprice;
this.btype = btype;
}
public Book(String bname, double bprice, String btype) {
this.bname = bname;
this.bprice = bprice;
this.btype = btype;
}
@Override
public String toString() {
return "Book [bid=" + bid + ", bname=" + bname + ", bprice=" + bprice + ", btype=" + btype + "]";
}
}
模糊查询分页:
com.zking.dao
package com.zking.dao;
import java.util.List;
import com.zking.entity.Book;
public interface IBookDao {
/**
* 带模糊查询的分页
* @param pageIndex 页数
* @param pageSize 每页几条数据
* @param str 名称的关键字
* @return 结果集合
*/
public List<Book> getAllByPage(int pageIndex,int pageSize,String str,String col);
/**
* 获得总行数
* @param str 表名等
* @return 总行数
*/
public int getRows(String str);
}
package com.zking.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import com.zking.entity.Book;
import com.zking.util.DBHelper;
publ