Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Moving Through a result Set on two tables

 
Chase Becicka
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with setting up my result set and when I query the database, I have two tables and they are linked by a common column name so I have to designate which one I call to the but when I set my second query to the second table I get a query already open error, because I queryed the first tables so how do I combine the two queries into one but avoid the problem of the Column with the same name, (The columns needs to be the same so changing them isn't an option)

 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure I understand exactly what you are trying to do, but why cant you have two independent statement objects for two tables.
 
Chase Becicka
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you mean by having two object statments, but how would that work and if I were pulling info outta the database how would that work for the code below I just pasted below assuming that lets say 1/2 of the items I was trying to set were for a different table

 
Sonny Gill
Ranch Hand
Posts: 1211
IntelliJ IDE Mac
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From JavaDocs for java.sql.Statement -

By default, only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. All execution methods in the Statement interface implicitly close a statment's current ResultSet object if an open one exists.


What I was saying was, have two Statements for the two ResultSets you need from two different queries, and then you can do whatever you want with those

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic