jsp分页技术用oracle实现,详细的jsp分页(oracle+jsp+apache)_jsp技巧

本文提供了一个详细的使用Oracle数据库、JSP和Apache进行分页查询的示例程序。首先创建视图并用序列号为ID字段自增,然后通过Java的JDBC连接数据库,执行SQL查询获取数据并计算总页数。程序展示了如何根据用户输入的页码获取指定页面的数据,同时提供了首页、上一页、下一页和尾页的导航链接。
摘要由CSDN通过智能技术生成

我的一个详细的jsp分页程序!(oracle+jsp+apache)

一 前提

希望最新的纪录在开头给你的表建立查询:

表:mytable

查询:create or replace view as mytable_view from mytable order by id desc 其中,最好使用序列号create sequence mytable_sequence 来自动增加你的纪录id号

二 源程序

Class.forName(“oracle.jdbc.driver.OracleDriver”);

Connection conn=DriverManager.getConnection(sConn,”你的用户名”,”密码”);

Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

Statement stmtcount=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

ResultSet rs=stmt.executeQuery(“select * from mytable_view”);

String sqlcount=”select count(*) from mytable_view”;

ResultSet rscount=stmtcount.executeQuery(sqlcount);

int pageSize=你的每页显示纪录数;

int rowCount=0; //总的记录数

while (rscount

int pageCount; //总的页数

int currPage; //当前页数

String strPage;

strPage=request.getParameter(“page”);

if (strPage==null){

currPage=1;

}

else{

currPage=Integer.parseInt(strPage);

if (currPage<1) currPage=1;

}

pageCount=(rowCount+pageSize-1)/pageSize;

if (currPage>pageCount) currPage=pageCount;

int thepage=(currPage-1)*pageSize;

int n=0;

rs.absolute(thepage+1);

while (n

%>

rscount.close();

stmt.close();

stmtcount.close();

conn.close();

%>

//下面是 第几页等

&type=” onSubmit=”return testform(this)”>

第页 共页 共条

1){%>&type=”>首页

1){%>&condition=&type=”>上一页

&condition=&type=”>下一页

1){%>&condition=&type=”>尾页

跳到页

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值