473,769 Members | 3,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help needed Urgently with multiple result sets !!

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


public static void main(String[] args) {

try
//JDBC
{
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;

while(true)
{

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

long rowcnt = 0;

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

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

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


}
Oct 31 '06 #1
0 2960

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

Similar topics

2
3623
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?
28
3306
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...
8
5480
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
5
8681
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.
5
1918
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...
13
1999
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
53
4756
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:
0
2451
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...
0
9579
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9422
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,...
0
10206
Oralloy
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...
0
10035
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9851
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8863
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6662
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();...
0
5293
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...
2
3556
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.