473,839 Members | 1,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help needed Urgently with multiple result sets !!

4 New Member
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 DataOutputStrea m dos;
static ResultSetMetaDa ta rsInfo;

public static void main(String[] args) {

Class.forName(" com.ibm.db2.jcc .DB2Driver");
System.out.prin tln("Driver loaded...");

Connection db2Conn = DriverManager.g etConnection("j dbc:db2://id addr/TEST_DB", "user ","pwd");
System.out.prin tln("Conn established..." );

// use a statement to gather data from the database
CallableStateme nt cstmt = db2Conn
.prepareCall("{ ? = CALL ESCRIP.EXPORTDD S(?, ?, ?));
// set the place holders values with appropriate data types
cstmt.registerO utParameter(1, Types.INTEGER);
cstmt.setTimest amp(2, new Timestamp(2006, 04,01,00,00,00, 0));
cstmt.setTimest amp(3,new Timestamp(2006, 05,01,00,00,00, 0));
cstmt.registerO utParameter(4, Types.VARCHAR);
// Execute stored procedure
boolean resultsAvailabl e = cstmt.execute() ;
// Get the return value
final int error = cstmt.getInt(1) ;
System.out.prin tln("error: " + error);
ResultSet rs;


if(resultsAvail able)
rs = cstmt.getResult Set();

long rowcnt = 0;

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

resultsAvailabl e = cstmt.getMoreRe sults(Statement .KEEP_CURRENT_R ESULT);
if(!resultsAvai lable)

resultsAvailabl e = cstmt.getMoreRe sults(Statement .CLOSE_ALL_RESU LTS);
// Close all resources
db2Conn.close() ;
catch (SQLException sqle) {
sqle.printStack Trace();
catch (Exception e) {
e.printStackTra ce();

Oct 31 '06 #1
0 2972

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

Similar topics

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 object name is ommited. I only need the first result set. How do I do that?
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 make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
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 -------------------------------------------------------------------------------- Hello, I have a very simple problem but cannot seem to figure it out. I have a very simple php script that sends a test email to myself. When I debug it in PHP designer, it works with no problems, I get the test email. If
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 >1 result sets. Thought about global temp tables.
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 library called amebsa.c. The routine requires several parameters of the following form. *iter, **p, *yb.... . How does one initialize these variables? If I declare them as pointer (in this case, *yb and *iter) the compiler still tells me that it...
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 badly,urgently before monday please send it to my mail address i shall be thankful , Regards
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, and .Net2005 code. I'm developing in vb.net 2005. This test sub just reads an input text file, writing out records to another text file, eliminating records that have a '99' in them (it is similar to a CSV file). Some of my concerns are:
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 the whole. I really need MySQL wizz to give me a hand (and maybe refer me to books to get me to the wizz level myself). First off, english is a second language to me and sometimes my sentences might be a little awkward. Please forgive me. Mon...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.