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 processing result sets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "processing result sets" Watch "processing result sets" New topic

processing result sets

joe weakers
Ranch Hand

Joined: May 31, 2004
Posts: 38
Hello there. Is it possible to process a JDBC ResultSet more than once. What I mean is that I want to pass a single result set argument to two different methods that both process the result set in its entirety. Code looks as follows:

OracleResultSet ors1 = (OracleResultSet)stmt1.executeQuery(query1);

Both the methods parse the entire result set as follows:
while (
{ ...

Problem is that the result set is empty once the checkCFCC method has finished executing. I tried to intorduce a new OracleResultSet variable as follows:

OracleResultSet ors2 = ors1;

and then pass the two different result sets into the two methods. This did not solve my problem. Can anybody give me a pointer towards a possible solution. Thnaks a lot. Joe

Joined: Apr 18, 2004
Posts: 1
Hi Joe,
It is possible to process a resultset more than once,if the resultset is scrollable.By default resultsets are forward only,so in that case you can not process more than once.If the mentioned 2 methods are running in threads using same resultset objects,or objects pointing to same resultset,then the repurcations are not known.
ideally one should store the data in a simple java bean and do the further processing on the same.
Let me know your thoughts.

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33102


We're pleased to have you here with us in the JDBC forum, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Forum Bartender

[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
joe weakers
Ranch Hand

Joined: May 31, 2004
Posts: 38
Hi Samir. Thanks a lot for your reply. I have a little experience with Java beans and from what I hear they are not too difficult to master. However given the choice of employing either a scrollable resultset or using java beans I think I would rather go with the scrollable resultset option. can you give me some advice on how to incorporate the scrollable resultset or where to find some sample code on scrollable resultsets. Thnaks a lot, Joe
I agree. Here's the link:
subject: processing result sets
It's not a secret anymore!