新的面试题

zhaoyuanyuan1981 2005-11-01 11:53:44
JSP是怎么样实现分页的
...全文
480 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
vino_beer 2005-11-02
  • 打赏
  • 举报
回复
题目怎么这么别扭, 各位的答案和JSP有什么关系?
Croatia 2005-11-01
  • 打赏
  • 举报
回复
每次取需要的纪录,显示出来。
yanxiazhiqiu 2005-11-01
  • 打赏
  • 举报
回复
新的...

有两种解决方案,一种是第一次把所有的资料都查询出来,然后在每页中显示指定的资料;另一种是多次查询数据库,每次只获得本页的数据。建议第二种。
zealVampire 2005-11-01
  • 打赏
  • 举报
回复
oracle: 如果想前面翻业快些应该是先rownum < 20 再rownum > 10

------------->>是查询20到30的,可能写的会有点问题, 楼下的补充修改一下。
mssql :
select top(10) * from table where id not in (select top 20 id from table order by column1)

---------
oracle 也可以使用select * from table where id not in (select id from table where rownum < 20) where rownum > 10
wb0622 2005-11-01
  • 打赏
  • 举报
回复
如果你的查询量不大,可以一次性的把数据查询出来,放在一个集合里,然后从集合里取数据进行分页.
如果你查询量大,建议从数据库里分批取出数据进行分页.
zealVampire 2005-11-01
  • 打赏
  • 举报
回复
mssql :
select top(10) * from table where id not in (select top 20 id from table order by column1)

---------
oracle 也可以使用select * from table where id not in (select id from table where rownum < 20) where rownum > 10

---------

其实原理都是一样的, 但是可能就是数据越多, 查询就越漫的。

可能用游标还快些, 或者叫人写好些的存储过程。
zealVampire 2005-11-01
  • 打赏
  • 举报
回复
未经过严格验证:
mysql:(10-20的记录)
select * from table order by column1 limit 10, 20

oracle:(这个sql可能会错,只是标明镶嵌的用法)
select * from (select table.*, rownum rnum from table order by table.id where rownum > 10 ) where rnum < 20

mssql:(不知道top n的写法能写出来不?
------------------------
至于其他使用ResultSet游标获取每叶数据的方法
可以看看jsp版本的 FAQ
iamliming 2005-11-01
  • 打赏
  • 举报
回复
数据记录不多可以用取出所有数据。
记录多就要取本页的数据。

62,629

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧