File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes regarding the topics posted in javaranch Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "regarding the topics posted in javaranch" Watch "regarding the topics posted in javaranch" New topic
Author

regarding the topics posted in javaranch

Prasath Thirumoorthy
Ranch Hand

Joined: Jul 23, 2004
Posts: 65
Hi Friends,

Consider this forum page where we are placing all our queries.In each page there are about 40 questions.The Page no are given below as Page 12345678>> like this when we click on the respective page no it will show the respective page which contains around 40 queries in that page.How this is done using java code or any sql statments ?

Give me example code and detailed explanation in this.

Thanks & Regards
Prasath Thirumoorthy


Thanks,
Prasath

SCJP1.4, SCWCD
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14268
    
  21

Ok, suppose you have a database containing the topics, with one row in a table for each topic.

If you know that you want to display 40 topics per page, you can find out the number of pages by executing an SQL query like this:

SELECT COUNT(*)/40 FROM TOPICS

If you want to select the topics from a specific page, you'll have to specify this in the SQL statement, but unfortunately there is no (AFAIK) standard way to do this in SQL. In MySQL, you can use the LIMIT keyword like this:

SELECT * FROM TOPICS ORDER BY timestamp LIMIT 120,40

This selects 40 rows, beginning with row number 120 that the query itself returns, but as I wrote, it's MySQL specific SQL syntax.

In Oracle you'd have to do things with ROWNUM, and in other databases it works differently again.

So, look it up in the documentation for your particular database.
[ October 19, 2005: Message edited by: Jesper de Jong ]

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Prasath Thirumoorthy
Ranch Hand

Joined: Jul 23, 2004
Posts: 65
Hi Jesper de Jong
I understood the putting the topics in n no of pages but i couldn't get it the second part.If the user click on the particular page how it wil get the things in on that specific page.Bcos in the second u placed 120 as the beginning row but in the run-time it may vary how it done.This same kind of scenario u could find in Google Search also there u may n no of pages but if we click on particular page it shows the particular page details.Pleae tell me more abt it.

Thanks & Regards,
Prasath Thirumoorthy
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Each "1 2 3 4 5" link encodes a starting index; therefore when the link is pressed the server knows where to start the requested page.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding the topics posted in javaranch