zohab Posted November 28, 2012 Share Posted November 28, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/271296-mysql_num_rows-equivalent-in-jsp/ Share on other sites More sharing options...
requinix Posted November 28, 2012 Share Posted November 28, 2012 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). Quote Link to comment https://forums.phpfreaks.com/topic/271296-mysql_num_rows-equivalent-in-jsp/#findComment-1396007 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.