473,394 Members | 2,160 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Help needed Urgently with multiple result sets !!

4
Hi,
Following java code returns 24 result sets.It counts number of rows in the first result set correctly.But doesnt count rows from next result set.
When I debugged the code I found out that first time it enters in the loop while(rs.next()).But from the next result set it doesn't enter that loop as rs.next() returns false.DB2 is used as backend.
thanx 4 help.

import java.sql.*;
import java.io.*;

public class exportdds33 {
static DataOutputStream dos;
static ResultSetMetaData rsInfo;


public static void main(String[] args) {

try
//JDBC
{
Class.forName("com.ibm.db2.jcc.DB2Driver");
System.out.println("Driver loaded...");

Connection db2Conn = DriverManager.getConnection("jdbc:db2://id addr/TEST_DB", "user ","pwd");
System.out.println("Conn established...");


// use a statement to gather data from the database
CallableStatement cstmt = db2Conn
.prepareCall("{? = CALL ESCRIP.EXPORTDDS(?, ?, ?));
// set the place holders values with appropriate data types
cstmt.registerOutParameter(1, Types.INTEGER);
cstmt.setTimestamp(2, new Timestamp(2006,04,01,00,00,00,0));
cstmt.setTimestamp(3,new Timestamp(2006,05,01,00,00,00,0));
cstmt.registerOutParameter(4, Types.VARCHAR);
// Execute stored procedure
boolean resultsAvailable = cstmt.execute();
// Get the return value
final int error = cstmt.getInt(1);
System.out.println("error: " + error);
ResultSet rs;

while(true)
{

if(resultsAvailable)
{
rs = cstmt.getResultSet();

long rowcnt = 0;

//count no. of rows
while(rs.next())
rowcnt++;
System.out.println("No. of rows:"+rowcnt);

}
resultsAvailable = cstmt.getMoreResults(Statement.KEEP_CURRENT_RESULT );
if(!resultsAvailable)
break;
}

resultsAvailable = cstmt.getMoreResults(Statement.CLOSE_ALL_RESULTS);
// Close all resources
cstmt.close();
db2Conn.close();
}
catch (SQLException sqle) {
sqle.printStackTrace();
}
catch (Exception e) {
e.printStackTrace();
}
}


}
Oct 31 '06 #1
0 2940

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Darko Jovisic | last post by:
Hi! Another silly question: If a stored procedure returns multiple result sets, how do I choose the one I want to insert into a table? For example sp_spaceused returns two result sets if...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
5
by: Stanley Sinclair | last post by:
I have a need to return multiple result sets from a stored procedure. Want that SP to call others to get the data. Win2003, db2 8.1.5. Can't figure out how to handle open cursors, and return...
5
by: el prinCipante | last post by:
I'm getting tired of the following error message. Compiler Error message : Error: Need explicit cast to convert from: float to: float * I am trying to use a routine from the Numerical Recipes...
13
by: Gohar | last post by:
Any one please send me the C++ code for arithmatic calculator using linked lists Which performs addition ,subtraction,multiplication,division and modulus(using operator overloading). i need it...
53
by: Hexman | last post by:
Hello All, I'd like your comments on the code below. The sub does exactly what I want it to do but I don't feel that it is solid as all. It seems like I'm using some VB6 code, .Net2003 code,...
0
by: Chuck36963 | last post by:
Hi all, I've been working on a listing problem and I can't figure out how to work it out. I have looked far and wide on the web to find answers, but I'd like other peoples input on my project in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.