wood burning stoves 2.0*
The moose likes JDBC and the fly likes obtaining one result set at a time from multiple select Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "obtaining one result set at a time from multiple select" Watch "obtaining one result set at a time from multiple select" New topic
Author

obtaining one result set at a time from multiple select

john mattucci
Ranch Hand

Joined: Nov 03, 2000
Posts: 331
Calling a stored procedure which returns multiple result sets. My problem which I cant seem to figure out; when I call cs.getResultSet() all result sets are returned ie 4. Im using ThinWeb Technologies(tm) Driver Version 1.3 for MS SQL Server. Why is this happening???
CallableStatement cs = myCon.prepareCall("{call initial_info (?)}");
cs.setInt(1, InfoGetter.locationInt);

boolean success = cs.execute();
int i = 0;
while(success)
{
myRs = cs.getResultSet();
information[i] = new Vector();
do
{
if(i == 0 || i == 1)
information[i].addElement(new Integer(myRs.getInt(1)));
else if(i == 2)
information[i].addElement(myRs.getString(1));
else if(i == 3)
{
Object o[] = new Object[2];
o[0] = myRs.getString(1);
o[1] = new Integer(myRs.getInt(2));
information[i].addElement(o);
}
}while(myRs.next());
i++;
myRs.close();
success = cs.getMoreResults();
}
//close connections
myRs.close();
cs.close();
CREATE PROC initial_info(@location int)
AS
--1/
SELECT route From route WHERE location = @location
AND type = 0 ORDER BY [route] ASC;
--2/
SELECT number From bdrdsmnum WHERE location = @location
ORDER BY [number] ASC;
--3/
SELECT name From salereps WHERE location = @location
ORDER BY [name] ASC;
--4/
SELECT description, number From marketsegments;
GO
 
 
subject: obtaining one result set at a time from multiple select
 
Similar Threads
Need some serious help THANK U ALL
record lock&unlock
Stored procedure which returns array
translate to pig latin!? completely lost....
Need Help With Dynamic text box in JSP