Jump to content

Mysql_Num_Rows Equivalent In Jsp.


zohab

Recommended Posts

Hi,

 

I am developing pagination in JSP.

 

I want to get number of records return by query.

 

In PHP we have function mysql_num_rows which give count of rows return by query.

 

Any idea how to get number of rows in JSP.

 

PreparedStatement stat= conn.prepareStatement("SELECT AC_ID, AC_NAME, AC_PHOTO , AC_DESCRIPTION FROM AC_IMAGE_GALLERY ");
rs = stat.executeQuery();
nume = 11;
//$nume=mysql_num_rows($sqlResAll);

PreparedStatement stat2= conn.prepareStatement("SELECT AC_ID, AC_NAME, AC_PHOTO , AC_DESCRIPTION FROM AC_IMAGE_GALLERY WHERE ROWNUM >"+eu+" AND ROWNUM <"+limit+"");
rs2 = stat2.executeQuery();
num_rows = 10;
//$num_rows = mysql_num_rows($result);

 

- Thanks

Zohaib.

Link to comment
https://forums.phpfreaks.com/topic/271296-mysql_num_rows-equivalent-in-jsp/
Share on other sites

Looking at the docs on ResultSet and a bunch of results in Google suggests it's not possible. Which is understandable because there are cases where mysql_num_rows() doesn't work; it's only because mysql_query() buffers the results that you can use it.

 

Try buffering the results yourself, or rework your logic so that you don't need to know how many rows there are ahead of time (if at all).

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.