aspose file tools*
The moose likes JDBC and the fly likes working with multiple resultsets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "working with multiple resultsets" Watch "working with multiple resultsets" New topic
Author

working with multiple resultsets

pradeep samudrala
Greenhorn

Joined: Feb 21, 2007
Posts: 7
Hi,
is it possible to open multiple resultsets concurrently.i am having problems when working with resultset.i want to execute two sql statements and i need to compare the data(which is retreived from the database).so i have created two ResultSet objects.when i try to execute the class it is giving cursor closed error.can anybody help me in this regard.

Thanks in advance.
Herman Schelti
Ranch Hand

Joined: Jul 17, 2006
Posts: 387
hi,

If you post some of code, you will probably get the help you want.

Herman
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39535
    
  27
Only one ResultSet can be open per Statement (see the ResultSet javadocs for this). Thus, if you want multiple ResultSets, you need multiple Statements.


Ping & DNS - updated with new look and Ping home screen widget
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 852
Depends on what you mean. For example sybase jconnect driver allows you to return N ResultSets per query. I doubt you could iterate through them simultaneously. You could put them in some other data structure (arrayList for example) first.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
pradeep samudrala
Greenhorn

Joined: Feb 21, 2007
Posts: 7
Hi steve,
the solution you suggested is good.but the problem with the solution(guess) is it degrads the performance.let us suppose i have 1lac records in the table, retreiving them to some data structure like vector and accessing them from the vector could cause some performance degradation.instead of copying them to some datastructure,if we can access from the ResultSets concurrently then it could be a better solution.i am using ORACLEDATABASE(9i) and oracle thin driver.is it possible with this DRIVER.
Thanks in advance.
Chad Clites
Ranch Hand

Joined: Aug 16, 2005
Posts: 134
Is there any reason that you could not create a virtual table (using VIEW) that incorporates the data from both sets? Any time either data set is updated, the updates will be reflected in the virtual table. I don't know how you are comparing the data, but comparisons can be built into the table also. Then you would only need a single query.
Abhi Vuyyuru
Greenhorn

Joined: Mar 10, 2005
Posts: 12
It will be helpful if you can post some code that you are trying to use.

By the way, Did you think of using RowSet instead of ResultSet? This will avoid building a new data structure.


Abhi Vuyyuru
Blog: http://java-x.blogspot.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: working with multiple resultsets
 
Similar Threads
why we require execute() method?
JDBC API Tutorial - questions about the book
JDBC connection issues
java.lang.OutOfMemoryError: Java heap space while Executing the Query
Retrieving & Comparing data from database