-
displaying next 10 Records from resultset
Hi all
I am developing a website for some writers.
The website is database driven and contains writings and poetries
by different writers.
I am using servlet to connect to Database and using MySQL
as database.
I wanted to know that how can i display only some fields
from the recordset after search and then make the name of the
writer a hyperlink to next page which shows the details about
his/her work.
Also the data fetched into resultset should be displayed
on the page in such a way that only firt 10 records get displayed
in the first page and then i could navigate through rest
of the results using next and previous buttons.
Your help would be really appreciated..
Thank you in advance
Regards
Vikas
-
Re: displaying next 10 Records from resultset
First, your website isn't 'database driven'. It is user input driven with
persisted information that uses a relational database base for that persistance.
Most databases provide away to page the 'data'. I don't know MySql at all
but I downloaded the manual just now and didn't see a quick resolution.
Ok, I looked again and found something. This way would be database specific
(as it would with any other database). Use the LIMIT function. Order and
select the data as needed and use the LIMIT function to get the next or previous.
ie -
SELECT id, name FROM WRITINGS WHERE name > [namevar] ORDER BY name ASC
LIMIT 10
SELECT id, name FROM WRITINGS WHERE name < [namevar] ORDER BY name DESC
LIMIT 10
Another way (non-db specific) is to select where the key is greater than
the last key selected and read the next ten. Of course it will read according
to key and may not page the way you desire. So basically the next and previous
buttons would be links that call the servlet and pass the value they hold.
Download and read the MySQL manual. There is alot of helpful info in it.
-
Re: displaying next 10 Records from resultset
Why not hold the data in a ResultSet in a Bean there are also a few other
variables you need to store such as Record Count, current record number etc.
Then create when you request the data it comes out of the Bean and you get
10 records, set all the necessary counter variables and awaay you go.
Ok it's not that simple but not far off. You also have the option of wrapping
all this up in a Tag Library thereby giving you the ability to use a generic
ResultSet Bean.
"vikas dua" <vikasdua79@yahoo.com> wrote:
>
>Hi all
>I am developing a website for some writers.
>The website is database driven and contains writings and poetries
>by different writers.
>I am using servlet to connect to Database and using MySQL
>as database.
>I wanted to know that how can i display only some fields
>from the recordset after search and then make the name of the
>writer a hyperlink to next page which shows the details about
>his/her work.
>Also the data fetched into resultset should be displayed
>on the page in such a way that only firt 10 records get displayed
>in the first page and then i could navigate through rest
>of the results using next and previous buttons.
>
>Your help would be really appreciated..
>Thank you in advance
>
>Regards
>Vikas
-
Re: displaying next 10 Records from resultset
Vikas,
You mentioned a servlet, which of course implies Java as the technology behind
the database-driven site (yes, "database-driven" IS an accurate way of describing
your site; ignore the techno-elitist ramblings of dingleberries that tell
you otherwise). Anyway, if you are using Java, you have the full JDBC API
at your disposal; look into ResultSet.
Regards,
J.
"vikas dua" <vikasdua79@yahoo.com> wrote:
>
>Hi all
>I am developing a website for some writers.
>The website is database driven and contains writings and poetries
>by different writers.
>I am using servlet to connect to Database and using MySQL
>as database.
>I wanted to know that how can i display only some fields
>from the recordset after search and then make the name of the
>writer a hyperlink to next page which shows the details about
>his/her work.
>Also the data fetched into resultset should be displayed
>on the page in such a way that only firt 10 records get displayed
>in the first page and then i could navigate through rest
>of the results using next and previous buttons.
>
>Your help would be really appreciated..
>Thank you in advance
>
>Regards
>Vikas
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks