public class PageInfo {
private int pageNo = 1;// 当前页编号
private int dbIndex = 0;// 起始行,通常该属性通过pageNo和pageSize计算得到
private int pageSize = 5;// 每页显示条数
private int totalReacordNumber;// 总共的记录条数
private int totalPageNumber;// 总共的页数,通过总共的记录条数以及每页大小计算而得
public int getPageNo() {
return pageNo;
}
public void setPageNo(int pageNo) {
//在设置当前页码的时候,就同时设置分页起始行
int temp = (pageNo - 1) < 0 ? 0 : (pageNo - 1);
this.dbIndex = temp * pageSize;
this.pageNo = pageNo;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getDbIndex() {
return dbIndex;
}
public void setDbIndex(int dbIndex) {
this.dbIndex = dbIndex;
}
public int getTotalReacordNumber() {
return totalReacordNumber;
}
public void setTotalReacordNumber(int totalReacordNumber) {
if (totalReacordNumber % pageSize == 0) {
this.totalPageNumber = totalReacordNumber / pageSize;
} else {
this.totalPageNumber = totalReacordNumber / pageSize + 1;
}
this.totalReacordNumber = totalReacordNumber;
}
public int getTotalPageNumber() {
return totalPageNumber;
}
public void setTotalPageNumber(int totalPageNumber) {
this.totalPageNumber = totalPageNumber;
}
@Override
public String toString() {
return "PageInfo [currentPageNo=" + pageNo + ", dbIndex=" + dbIndex + ", dbNumber=" + pageSize + ", totalReacordNumber="
+ totalReacordNumber + ", totalPageNumber=" + totalPageNumber + "]";
}
}
2、定义实体对象User(User.java)
public class User {
private int id;
private String username;
private String password;
//setter(),getter()
}
3、完成实体对象User的映射文件(User.xml)
4、编写查询数据dao类(UserDao.java)
public class UserDao {
MybatisUtils mybatisUtils = new MybatisUtils();
SqlSession sqlSession = null;
// 通过手动写分页统计
public List queryListUser(User queryUser, PageInfo pageInfo) {
List userList = null;
try {
sqlSession = mybatisUtils.getSqlSession();
} catch (IOException e) {
e.printStackTrace();
}
//通过面向接口编程访问
IUser iUser = sqlSession.getMapper(IUser.class);
//设置请求参数,加入到map中
Map parameter = new HashMap();
parameter.put("user", queryUser);
//提前查询结果总数,放到pageInfo中
int count = iUser.count(queryUser);
pageInfo.setTotalReacordNumber(count);//注意在给pageInfo设置总数的时候会设置总页数
parameter.put("pageInfo", pageInfo);
//查询结果
userList = iUser.queryListUser(parameter);
return userList;
}
}
5、测试
UserDao dao = new UserDao();
User queryUser = new User();
queryUser.setUsername("a");
PageInfo pageInfo = new PageInfo();
pageInfo.setPageSize(2);
pageInfo.setPageNo(1);
List userList = dao.queryListUser(queryUser, pageInfo);
System.out.println(pageInfo);
for (User user : userList) {
System.out.println(user);
}
UserDao dao = new UserDao();
User queryUser = new User();
queryUser.setUsername("a");
PageInfo pageInfo = new PageInfo();
pageInfo.setPageSize(2);
pageInfo.setPageNo(1);
List userList = null;
pageInfo.setPageNo(2);
userList = dao.queryListUserByPage(queryUser, pageInfo);
System.out.println(pageInfo);
for (User user : userList) {
System.out.println(user);
}
openjdk上关于hotspot将移除永久带的描述非常详细,http://openjdk.java.net/jeps/122
JEP 122: Remove the Permanent Generation
Author Jon Masamitsu
Organization Oracle
Created 2010/8/15
Updated 2011/
PL/SQL也是一门高级语言,所以流程控制是必须要有的,oracle数据库的pl/sql比sqlserver数据库要难,很多pl/sql中有的sqlserver里面没有
流程控制;
分支语句 if 条件 then 结果 else 结果 end if ;
条件语句 case when 条件 then 结果;
循环语句 loop
/*
*开发子程序
*/
--子程序目是指被命名的PL/SQL块,这种块可以带有参数,可以在不同应用程序中多次调用
--PL/SQL有两种类型的子程序:过程和函数
--开发过程
--建立过程:不带任何参数
CREATE OR REPLACE PROCEDURE out_time
IS
BEGIN
DBMS_OUTPUT.put_line(systimestamp);
E
long 长的
show 给...看,出示
mouth 口,嘴
write 写
use 用,使用
take 拿,带来
hand 手
clever 聪明的
often 经常
wash 洗
slow 慢的
house 房子
water 水
clean 清洁的
supper 晚餐
out 在外
face 脸,