• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Resultset

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
IS it possible to define two resultset objects with two different queries inside the same DB class?
 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well yes. You can also use one ResultSet object with different queries.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Shobhit Khandelwal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can try this :
 
denis sorn
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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:

 
Sheriff
Posts: 21997
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JDBC.
 
Shobhit Khandelwal
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes Denis...I was actually meant to reuse a reference.
Thanks for correction
 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.


 
    Bookmark Topic Watch Topic
  • New Topic