hi !
please tell me how to navigate from 1st record to last record and also from last to first record of database using JDBC , Servlet and jsp.
please help me by sending full source code for that. thanks :)

After you have run the query, use the ResultSet and a while loop to save the results in a Vector. Then you can do whatever you want with the Vector at your servlet or jsp.

I suggest you study first how to run queries and get the results with java, which has nothing to do with jsps.

thanks...
i know how to run query and how to get values in result set using while loop already. ResultSet.next() and ResultSet.previous are the methods to scroll through resultset values i used all these in my program but there was sum prob in navigation.

anyways, thanks :)

i know how to run query and how to get values in result set using while loop already. ResultSet.next() and ResultSet.previous are the methods to scroll through resultset values i used all these in my program but there was sum prob in navigation.

Also, make sure you request a scroll insensitive ResultSet when preparing the statement so that you can move to the last row of the ResultSet and navigate it from last to first. Something like:

final Statement stmt = conn.prepareStatement("select * from tbl", ResultSet.TYPE_SCROLL_SENSITIVE);
final ResultSet rs = stmt.executeQuery();
if(!rs.last()) return; // no rows
while(true) {
  // process result set
  if(!rs.previous()) break;
}
// cleanup
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.