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
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).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.