• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to use IBatis to paging in jsp?  RSS feed

 
lyo Yashnoo
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone:
I'm a new comer in IBatis.If I query the database using the method "executeQueryForList" how to display the record in jsp (for example 10 record)? How to process the parameter?
If someone used it please help me.
Thks
 
Jasmine kaur
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Iam jasmine,
Well use statement.getResultSet(); which will return the refernce of ResultSet interface and the use next() method of resultset and then put in the loop as resulset will retrun the object. then use resultset.getString() method.
so code would be
ResutlSet rs=statement.getResultSet();
while(rs.next())
{
String s1=rs.getString(int column index);
out.println(s1);
}
but dont forget to close the resultset and put try and catch .
So I hope this will solve ur problem.

Thanks
Jasbir
 
lyo Yashnoo
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you
But I think the method "executeQueryforPaginatedList" will be better.Because it has associated method "nextPage(), previousPage(), gotoPage(),isMiddlePage(), isLastPage(), isNextPageAvailable(),".
What I want to know is how to display the page number according to the resultset.For example,If I want to display this in jsp:
"<<back 1 2 3 4 last>>>"
How to display the number "1,2,3,4"?
I means that if I query 10 record per time how to display it in jsp?
:roll:
 
Andres Gonzalez
Ranch Hand
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use the pager taglib for this. It does exactly what you want to achieve (automatically!!)...
just a suggestion
 
lyo Yashnoo
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I had use that pager taglib to paging and it is easy to use.But I find that (some O/R Mapping) either Hibernate or (SQL-Mapping)IBatis support some companient method for paging.For example ,Hibernate can get any count record per time.IBatis also can do this. So I can use them paging if I know the only one of them.
I am very want to master the one paging method of them.
Someone can help me?
Thanks :roll:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!