File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Two result set in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Two result set in JSP" Watch "Two result set in JSP" New topic

Two result set in JSP

Rashmi Trivedi
Ranch Hand

Joined: Aug 13, 2001
Posts: 60
Hello all
I am struggling to get two result set working in one JSP.

I am using Apache Tomcat and SQL Server as db server.

I have declared them with different variable however when i load the JPS, it comes us with runtime error.

"busy with another query or resultset"

could you please give me some advise or an example code would be highly beneficial as i have spent lot of time on this.

Thanks in advance - much appreciated.

Rashmi Trivedi
Rohit Dhodapkar
Ranch Hand

Joined: Apr 27, 2006
Posts: 38

I guess you should'nt bring the Result Sets in JSP and iterate them there. This is not a good practice. YOu should store the contains of the result sets in different Java Bean objects. And then iterate the beans in JSPs. This follows as Transfer Object and Value Object Pattern in J2ee design Patterns.

I guess you should disconnect the resultset first and then send it to JSPs if you want you current model to work to avoid Runtime exception .
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

I agree with Rohit as far as best practices go but it sounds like this specific problem is not directly related to the fact that the code is in a JSP.

Since this is more of a JDBC issue than a JSP issue, moving to JDBC.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

Are the two ResultSets from the same Statement object? Some drivers don't support that well. You could try using different Statement objects.

Feel free to post some code. This may help us give you a more specific answer.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
I agree. Here's the link:
subject: Two result set in JSP
jQuery in Action, 3rd edition