File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Moving Through a result Set on two tables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Moving Through a result Set on two tables" Watch "Moving Through a result Set on two tables" New topic
Author

Moving Through a result Set on two tables

Chase Becicka
Greenhorn

Joined: Feb 16, 2004
Posts: 23
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

Joined: Feb 02, 2002
Posts: 1211

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.


The future is here. It's just not evenly distributed yet. - William Gibson
Consultant @ Xebia. Sonny Gill Tweets
Chase Becicka
Greenhorn

Joined: Feb 16, 2004
Posts: 23
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

Joined: Feb 02, 2002
Posts: 1211

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

 
 
subject: Moving Through a result Set on two tables
 
Similar Threads
Need Help Pulling Data From Oracle Table (Newby)
jsf and database connection problem
What is -Xlint in compiling java program?why this is done?
removing a scrollpane, yet still see it
Solved : JTDS MSSQL Pagination problem.