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();
%>;
//下面是 第几页等
相关文档:
JSP基本语法
大部分JSP被一个以“”结尾的的标记括在其中。在更新的JSP 1.1规范出台后,就有了与XML兼容的版本。
JSP指令和脚本元素
Directives
Declarations
Expressions
Code Fragment/ ......
最近在一个论坛中和人讨论了一通关于ORACLE学习的问题,结合我也算有10年的ORALCE 使用学习的经历给大家一点建议吧。
1、ORACLE数据库是一个非常庞大,非常精深的系统,要有长期抗战的准备,你指望能在一个月内学会入门那是可以的,但是你要买本24天精通ORACLE数据库这样不负责责任的书,并想通过他来掌握ORACLE,只能是痴 ......
Oracle9i Database Release 2 Enterprise/Standard/Personal Edition for Windows NT/2000/XP
http://download.oracle.com/otn/nt/oracle9i/9201/92010NT_Disk1.zip
http://download.oracle.com/otn/nt/oracle9i/9201/92010NT_Disk2.zip
http://download.oracle.com/otn/nt/oracle9i/9201/92010NT_Disk3.zip
Oracle9i ......
1、创建表
create table stud(
sid int,
sname varchar2(50),
age number,
score number(4,2))
并插入一些数据(自己手动插入一些吧)
2、创建函数
create or replace function fun_getScores(
v_age in stud.age%type
)
return number
is ......
首先你要有tomcat,还要有oracle jdbc的jar档等环境.
第一步: 写JSP
String url="jdbc:oracle:thin:@(des ......