This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
1:->how can i find total no of records in database .?....
2:-> i want to find total no of records then i have to fetch only 5 records at a time so when i am firing a query 2 times such that
ResultSet rs1=st1.executeQuery("select * from "+table); // this ones for finding the total no of records
ResultSet rs=st.executeQuery("SELECT * FROM (SELECT "+table+".*, ROWNUM RN FROM "+table+" WHERE ROWNUM <="+upr +" ORDER BY ID) WHERE RN >" +lwr); // this ones for fetching 5 records at a time here lwr and upr are onlyy variables
now when i execute it i am getting nothin but an error so now please tell me how to resolve it
For getting all records in a table it's "select count(*) from table". You currently have the actual data returned.
For the fetching, depends on what DB you use. If you use say MySQL, you can use the LIMIT clause. If you use Oracle then rownum can be used but can't guarantee if the data order is the same every time.
You most likely need to store the from and to variables in some request attributes or something.
This concept is called Pagination.
When there are frequent insertions into a table, then it's difficult get different You have to do order by on set of records to get the data from DB.
Best way is to get the data from DB and display in application in Pagination manner.
Joined: Jun 18, 2013
yes i am also implementing it thats why i need this can you tell me the solution of this problem