aspose file tools*
The moose likes JDBC and the fly likes Resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Resultset" Watch "Resultset" New topic
Author

Resultset

Sachin Raju
Ranch Hand

Joined: Oct 29, 2009
Posts: 41
IS it possible to define two resultset objects with two different queries inside the same DB class?
denis sorn
Ranch Hand

Joined: Apr 30, 2008
Posts: 33
Well yes. You can also use one ResultSet object with different queries.
Shobhit Khandelwal
Greenhorn

Joined: Feb 19, 2009
Posts: 24
Yes, it is possible. In fact you should create different ResultSet objects for executing different queries, the other way round i.e. executing different queries with same resultset object before closing it will give an error. For specific solution supply your code.
Sachin Raju
Ranch Hand

Joined: Oct 29, 2009
Posts: 41
Getting this exception if I do so:::

java.sql.SQLException: Invalid state, the ResultSet object is closed.
at net.sourceforge.jtds.jdbc.JtdsResultSet.checkOpen(JtdsResultSet.java:299)
at net.sourceforge.jtds.jdbc.MSCursorResultSet.next(MSCursorResultSet.java:1123)
at DB5.getDetails(Daily_Quote_Response_report.java:238)
at Daily_Quote_Response_report.main(Daily_Quote_Response_report.java:74)
Sachin Raju
Ranch Hand

Joined: Oct 29, 2009
Posts: 41
Shobhit Khandelwal
Greenhorn

Joined: Feb 19, 2009
Posts: 24
You can try this :
denis sorn
Ranch Hand

Joined: Apr 30, 2008
Posts: 33
Hi both,

first sorry for the misguidance. As Shobhit said you can not reuse same ResultSet Object. What I actually meant you can reuse a reference.

And you don't have to create two Stramenet objects. This works for me:

Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19544
    
  16

Moving to JDBC.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Shobhit Khandelwal
Greenhorn

Joined: Feb 19, 2009
Posts: 24
Yes Denis...I was actually meant to reuse a reference.
Thanks for correction
swapnl patil
Ranch Hand

Joined: Aug 13, 2007
Posts: 80
yes, we can use same statement for more than one result set.




when we use following approach



result set rs will get closed automatically & when we try to fetch the data from rs it throws error.

so after
fetch the data form rs then go to
and fetch the data from rs1.


 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Resultset
 
Similar Threads
Matching a String with a certain record
Combining Resultsets
Does ResultSet close when connection closes?
Getting Resultset Close Error....
comparing two ResultSet