public static int getResultSetCount(ResultSet rs)
{
try
{
if(rs.next())
{
rs.last();
int i = rs.getRow();
rs.beforeFirst();
return i;
}
else
return 0;
}catch(SQLException e)
{
return 0;
}
}
{
try
{
if(rs.next())
{
rs.last();
int i = rs.getRow();
rs.beforeFirst();
return i;
}
else
return 0;
}catch(SQLException e)
{
return 0;
}
}
解决方案 »
- c:foreach中如何指定循环个数,就是最多只遍历5个
- 我新手,大家帮忙看看,错是什么原因???????????
- 求救:Tomcat的中文问题(在resin下一切正常,数据库用的mysql)
- 关于javabean的一个奇怪问题
- 为什么applet在JSP页面里面显示不出来,换成HTML的就行
- 大家一起努力,把TOMCAT连接各种数据库的程序汇总在一起,方便大家学习!!
- 关于jive显示发贴显示"???"得问题,怎么解决?在线给分
- SSH框架出现这个问题,,各位大神,求解决?,,,
- java 代码评审
- 这张图是用echarts做的吗??是用line3d吗?
- 推荐一下学习JSP的好书
- smartupload上传过来的文件,如何改名后存在硬盘啊
{
try
{
if(rs.next())
{
rs.last(); //将指针移动到最后一条记录
int i = rs.getRow(); //取得当前的位置 ! 即记录总数
rs.beforeFirst(); //将指针移动到最开始的位置,即0
return i;
}
else
return 0;
}catch(SQLException e)
{
return 0;
}
}
<%
int i = 类名.getResultSetCount(rs); //static方法。所以不用new.
%>
resultSet.next();
int rowcount=resultSet.getInt(1);
(注: class中指定 DBmanager 路径)
<%
ResultSet rs ;
int iCount = 0 ;
iCount = DBmanager.getResultSetCount(rs) ;%>
while(rs.next()){
......
countRows++;
......
}
//return countRows; /*****你可以选择返回或者用getter取出此数******/如果只要记录条数,推荐用SQL的方式/select count(*)....