Calling a SP from MSSQL and retrieving multiple resultsets

I have a SP on MSSQL and I am making a call to SP using CallableStatement.
here a snippet
<%! static Connection connection = null;%>
<%! private static CallableStatement cs1,cs2; %>
<%! private static ResultSet rs1,rs2; %>
<%
try{
Class.forName("net.sourceforge.jtds.jdbc.Driver").newInstance();
connection = DriverManager.getConnection("","username", "password");
System.out.println("Database connected");
cs1 = connection.prepareCall("{call GetTasksForCalendar (?,?)}");
System.out.println("1");
cs1.setString(1,"testts");
cs1.setString(2,"12/20/2006");
System.out.println("2");
boolean resultsetsavailable = cs1.execute();
while(resultsetsavailable)
     System.out.println("a");
     ResultSet rs = cs1.getResultSet();
     ResultSetMetaData rsmd = rs.getMetaData();
System.out.println("Column count"+rsmd.getColumnCount());
     System.out.println("b");
     while(rs.next())
     System.out.println("c");
     System.out.println("d");
     System.out.println("e");
     resultsetsavailable = cs1.getMoreResults();
     System.out.println("f");
     System.out.println("3");
%>
<%}catch(Exception e){}
finally{
%>The out put is like this (it returns totally 8 result sets)
Database connected
1
2
a
Column count8
b
e
f
a
Column count8
b
e
f
a
Column count8
b
e
f
a
Column count8
b
e
f
a
Column count8
b
e
f
a
Column count8
b
e
f
a
Column count8
b
e
f
3You can observe that the code within while(rs.next()) is not getting executed. When I print rs.next() it is printed "false".
the store procedure is returning multiple result set values.
Any suggestions or help i can expect for???
thanks so much
Rk.

Try setting rs to null after each loop.As i
faced the same problem with ms access and it
worked.Hopefully it helps you out.You wrote a stored procedure in MS AccessMS-SQL Server, nobody said anything about Access.Okay never mind I misread your post and I have no clue what Ashitosh is on about.

Similar Messages

  • Calling stored procedure and returning multiple resultsets

    Hello,
    Is it possible to create a procedure that return multiple result sets?
    e.g.
    procedure GetDataFromTables() is
    begin
    select * from table_one;
    select * from table_two;
    end GetDataFromTables;
    And I want to call this procedure that returns multiple resultsets (one for table_one and another for table_two)
    I have referred to the OCCI sample occiproc.cpp, but I am not sure how to handle multiple resultsets.
    Your help is highly appreciated.

    Thank You,
    Got the REF cursor in storedproc.cpp.
    But as it is documented, getCursor() gets the REF CURSOR value of an OUT parameter as a ResultSet.
    So, is it true that if I have to write a procedure that selects * from 50 tables (50 SQL statements) , I have to set 50 OUT parameters to get the result sets.?
    Is there any better way of doing this?
    e.g. in DB2, we can open multiple cursors in the procedure body and then get the result set one after another.
    CREATE PROCEDURE get_staging_data ()
    RESULT SETS 1 <no. of result sets>
    LANGUAGE SQL
    BEGIN ATOMIC
    DECLARE L_SQL varchar(5000);
    DECLARE c CURSOR WITH RETURN TO CLIENT FOR L_STMT;
    SET L_SQL = '';
    SET L_SQL = 'SELECT * FROM ';
    SET L_SQL = L_SQL || IN_Tab_Name ;
    SET L_SQL = L_SQL || ' WHERE VERIFY_FLAG=''S'' FOR READ ONLY OPTIMIZE FOR 2000 ROWS' ;
    PREPARE L_STMT FROM L_SQL;
    OPEN c; < can open multiple cursors in the prodedure body>
    END

  • Calling JSP file from applet and passing a parameter in POST form

    Hi,
    Can anybody help me. I want to call a JSP page from within a applet and to this JSP page i want to pass the query which the applet has created in POST method.
    I want to refresh the applet page with the new JSP page by passing the query object so the jsp page with take this query, and display the resultset
    Thanks in advance
    JK

    Review
    URL.openConnection()
    and HttpURLConnection

  • Calling HTML file from servlet and vice versa...

    i have got few questions..
    1- if a site is made in HTML then what should be used to put user login functionality in it, servlets or jsp or other option(specify)?
    2- im trying to do with servlets, so when im calling doPost method from HTML page and sending data, everything working fine but because of this the page refreshes and the HTML coding get lost, so how can i stop that from happening if possible, like showing the same page with messege = "Logged in".
    3- how can i call an HTML page from servlet?
    4- how can i send data from servlet to HTML page?

    that i m aware of, but when a servlet is called then the page will refresh n it will display the things that you have mentioned in the servlet file n not the things that u have mentioned in HTML file, n the page will be blank if u have not mentioned any HTML coding in servlet file.
    so i need to knw how to call back that prev HTML file so that the things i want to display can be displayed, i knw the same can be done by adding the HTML code in servlet file but i would like to know if there is any way to call back the HTML file.

  • Calling an Oracle stored procedure and retrieving result from OUT parameter

    Hello,
    I have a stored procedure that returns a string in an OUT parameter after receiving 6 IN parameters. I have tested the procedure in PL/SQL and it's producing the right output there. The problem is when I call the stored procedure from my Java method. I then get an error message telling me that I have the wrong number or types of arguments in my procedure call. I have checked that the method receives and sends the correct data in the correct order and I'm not sure what else the error message can relate to...?
    The exception is called on my second try statement but I haven't been able to find out what I have done wrong there. Does anyone have any suggestions? Thanks.
    the error message
    java.sql.SQLException: ORA-06550: line 1, column 13: PLS-00306: wrong number or types of arguments in call to 'P_SET_GIVEN_ANSWER' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
    the procedure
    CREATE OR REPLACE PROCEDURE p_set_given_answer(
    strfeedback OUT VARCHAR2,
    intpi_id IN INTEGER,
    intquestion_id IN INTEGER,
    intgivenanswer IN INTEGER,
    strgivenprefix IN VARCHAR2,
    strgivenunit IN VARCHAR2,
    strgu_id IN VARCHAR2) AS
    -- some declarations
    BEGIN
    -- some processing and then returns the string below indicating the outcome
    strfeedback = 'result';
    END
    the java method (the class is called dbUtil and the database connection is created in the method called getDbConnection() )
    public void setGivenAnswer(int intPi_id, int intQuestion_id, int intGivenAnswer, String strGu_id, String strGivenPrefix, String strGivenUnit) {
    java.sql.Connection con = null;
    String query = "{call ? := p_set_given_answer(?,?,?,?,?,?)}";
    try {
    con = dbUtil.getDbConnection();
    } catch(Exception e) {
    dbConnectionExceptionMessage = "error 1:"+e.toString();
    try{
    CallableStatement stmt = con.prepareCall(query);
    // register the type of the out param - an Oracle specific type
    stmt.registerOutParameter(1, OracleTypes.VARCHAR);
    // set the in params
    stmt.setInt(2, intPi_id);
    stmt.setInt(3, intQuestion_id);
    stmt.setInt(4, intGivenAnswer);
    stmt.setString(5, strGivenPrefix);
    stmt.setString(6, strGivenUnit);
    stmt.setString(7, strGu_id);
    // execute the stored procedure
    stmt.execute();
    // retrieve the results
    strFeedback = stmt.getString(1);
    } catch (java.sql.SQLException e) {
    dbConnectionExceptionMessage = "error 2:"+e.toString();
    try {
    con.close();
    } catch (java.sql.SQLException e) {
    dbConnectionExceptionMessage = "error 3:"+e.toString();
    ----------------------------------------

    Looks like you are declaring a procedure, but you are calling it like a function. A procedure has no return value, it has only parameters: "{call p_set_given_answer(?,?,?,?,?,?,?)}"

  • How To : Call External Webservice from BPEL and pass SOAP Message to the WS

    Hello All-
    Greetings to all BPEL gurus. I am currently facing difficulties in calling an External Webservice from my BPEL Process and passing SOAP Message to it. The details are below:
    <strong>1. The BPEL process, using database polling feature of DB Adapter, will get the records from the database.</strong>
    <strong>2. Transform the message</strong>
    <strong>3. Call the External Webservice and pass the transformed message as the input to it. However the Webservice expects the BPEL process to send SOAP headers in the input message.</strong>
    I am struggling on how to put the transformed message within a SOAP envelope in the BPEL process.
    If anyone had similar requirements and have successfully been able to send SOAP messages from BPEL process to an external webservice, kindly let me know.
    Also if there is some kind of documentation or any link in the forum that I can refer, please let me know that as well.
    I am new to Webservice integration using BPEL and would really appreciate your help.
    Thanks In Advance
    Regards,
    Dibya

    Hi Dharmendra,
    I am trying to send a SOAP message from my BPEL process to a web service. I have a complete SOAP message in a complex variable defined in the wsdl for the partnerlink (web service). My problem is that when I invoke the partnerlink it fails even though the content shown in the BPEL console looks valid.
    I have set up obtunnel to see what I am actually sending out from BPEL. You mention that BPEL creates the SOAP envelope automatically.
    I think that my problem is a result of this automatic SOAP envelope that BPEL is creating. Do you know if there is a way to turn it off?
    This is what I see in the TCP monitor, please note the double SOAP env:Body:
    <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <env:Body> <RCMR_IN000002NR01 xmlns="urn:hl7-org:v3" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
    <env:Header>
    <wsa:To xmlns:wsa="http://www.w3.org/2005/08/addressing">http://testhost/CCS/Service_Endpoint</wsa:To>
    <wsa:From xmlns:wsa="http://www.w3.org/2005/08/addressing">
    <wsa:Address>http://localhost/CCS/Service_Endpoint</wsa:Address>
    <wsa:Metadata>
    <device xmlns:hl7="urn:hl7-org:v3">
    </device>
    </wsa:Metadata>
    </env:Header>
    <env:Body>
    <RCMR_IN000002NR01>
    </RCMR_IN000002NR01>
    </env:Body>
    </RCMR_IN000002NR01>
    </env:Body>
    </env:Envelope>
    Any help is appreciated.
    Regards,
    Aagaard
    Edited by: Aagaard on Oct 30, 2008 8:59 PM
    Should have mentioned. I am using BPEL 10.1.3.4
    Edited by: Aagaard on Oct 31, 2008 8:43 AM
    I have opened a new thread for this question so as to not confuse the issue more than necessary.
    How many SOAP envelopes do you really need?

  • HOW TO - Create new from clipboard and process multiple files - please help

    Need help - have new version of photoshop on trial only ATM...
    Want to know - HOW TO:
    1. Create new from clipbaord
    2. Process multiple files
    Please help.

    For clipboard copy, I start with File > New and the size will be set to what's in the clipboard. Then once the new file is opened, Edit > Paste will place the clipboard contents as a layer in the new document.
    You must remember to use the command Layer > Flatten Image of you want to save as jpeg or any other file format that doesn't support layers.
    For processing multiple files,
    File > Automate > Batch or
    File > Scripts > Image Processor...
    Check the User guide or google information for those commands if you have specific needs.
    Gene

  • Does calling class methods from bean and JSP cause collision?

    Hi,
    Please look at the class below:
    public class X
    // no member variable
    public X() {}
    // pay attention to static keyword
    public static int getY()
    Think a bean (say BeanZ) that make calls to getY() method without initializing the class X (like this: X.getY() )
    And think many users having "page scope" in JSP make call to BeanZ or directly calls it from JSP.
    I'm wondering if any collision occurs because of STATIC method? Should I use "SYNCHRONIZED" keyword with it? If so, what about Math.cos() which also is a non synchronized static method ? Shouldn't I use Math.cos() (and the other static methods) in JSP or bean?
    Thank you for your help.
    Ali Sadik

    Hi,
    Thank you for your quick answer. Think my class like this:
    public class X
    // no member variable
    public X() {}
    // pay attention to static keyword
    public static int[] getY(int a, int[] b)
    // i know there is no need for the extra array.
    // just for example ;)
    int[] ret = new int[b.length];
    for(int i = 0; i < b.length; i++)
    ret[i] = a * b;
    return ret;
    Does it the type of class that you've mentioned ? It makes calculation to produce dynamic result. Shouldn't I use it as static ? If your answer is yes, what about Math.cos()? Doesn't it have dynamic calculation?
    Thanks a lot.

  • Calling one program from another and gettting values back

    Hello All,
    I am calling subroutine program X from a payroll function.  I am not able to get internal table back in my payroll program.
    This subroutine in program X is being used by some other reports in folLowing way and successfully returns values.Following sysntx is being used in suucessful implemetaiton of this piece of code.
    perform fill_rt2 (RPXXXX) USING BEGDA ENDDA PERNR.
    If i try doing that from payroll function, rt2 gets refreshed once control comes back to payroll.
    Please help.
    Thanks
    Samir

    try this ...
    Do not declare RT2 in both programs, only declare it in Calling progrm HNZLCALC0.
    Then use perform like this:
    perform GET_RESULTS (hnzuclro) using begda endda pernr CHANGING RT2.
    and ...
    Caller prpgram HNZUCLR0 : rt2 declared here in main program <- remove RT2 from here
    FORM GET_RESULTS using begda endda pernr CHANGING RT2
    FILL RT2.
    ENDFORM.
    let me know if it works, I do not have SAP right now, I can check syntax in the morning.

  • HT4009 I downloaded a game on my Iphone called shopping story from storm8 and purchased coins with diamonds that were not intended for it. How can I reverse it?

    Hi, I purchases an app on my Iphone, called fashion story, by STORM8. My Storm id is purrrrfection and I'm at level 19. I made an accidental purchase of 100,000 coins for 100 diamonds and and I also accidentally purchased ankle bracelet for around 25000 coins or 50000 coins, don't really remember. How can I reverse it?

    If you want to return your iPhone, you must do so through whoever you purchased the iPhone from. If that was someone other than an Apple Store, either online or physical, then that dealer's return policies will apply; Apple will have nothing to say about it. You may have to talk to Sprint in regards to your contract with them. I believe you have 30 days to return your phone and cancel your contract, but I'm not certain about Sprint.
    iTunes works fine under Windows on many, many systems, including Acer. Perhaps if you'll post details here, someone can help you sort things out. The thread you refer discusses an earlier version of iTunes and probably no longer applies even if that were the problem on your system, though I cannot say with certainty.  Note that if you are running Windows 7 Starter on your netbook, that version is reported to have problems with a lot of software, not just iTunes. Many people have installed and run iTunes quite successfully, though.
    they claim iTunes is a whole seperate brand from Apple computers they know nothing about
    I don't know who you talked to, but either there was a misunderstanding - the statement would apply perhaps to the iTunes Store, but not to iTunes as a program - or that person was an idiot. iTunes, the program, is most definitely an Apple product and should be supported fully by the Apple Store technical staff.
    Regards.

  • Calling GUI jar from C++ and setting parent for JDialog

    Hi,
    i am calling a GUI jar from in C++ code using ShellExecuteEx API as follows.
    l_sei->cbSize=sizeof(SHELLEXECUTEINFO);
              l_sei->fMask = SEE_MASK_NOCLOSEPROCESS;
              l_sei->hwnd =l_hwndFound;          
              l_sei->lpVerb = "open";
              l_sei->lpFile = "java";     
              l_sei->lpParameters ="test.jar";
              l_sei->lpDirectory = NULL;
              l_sei->nShow = SW_HIDE;
              l_sei->hInstApp = NULL;
              ShellExecuteEx(l_sei);This GUI opens up from the parent application .
    The problem i am facing is the jar runs as an independent application. I want to set application as the parent window for my GUI.
    The frame is a JDialog. Can i set a parent for a JDialog? So that doing Alt+Tab would not open the GUI on any window other than the parent application.
    thanks.

    Well, you can certainly set a parent for a JDialog (an owner, anyway, since it isn't a "parent" in the GUI hierarchy)... but that won't necessarily make the windows task switch together.
    Now, the real problem is that the "parent" needs to be a Java Dialog or Frame object in the same JRE as the dialog, and in order to get what OS-specific task switching features can be provided by AWT, it needs to be set at the Dialog's creation. Since a JDialog does have a native peer at some level, (although I'm not sure if it actually would be a native dialog window), you might be able to use the Java Invocation API instead of ShellExecuteEx to set up the JAR, watch for the JDialog to be created, and then link its peer through native code... but I don't think there's any easy way to do what you want, since Java windows aren't even supposed to be aware of native ones.

  • Calling Web services from ADF and JSF Jdeveloper 10.1.3.1

    Hi I need some examples/documentation about building a ADF application (user interface JSP pages) using only web services calls, instead of EJB or any other entities.
    For example, one web service would give details for a customers (parameters ID, Name,etc), another web service return all orders for a specific customer (parameter customer ID), and so.
    Somne advice, tutorial??
    Thanks!
    John.

    Thanks... I already saw this demo, very good, but uses web service input parameter in one page and result in another,
    But in my case I have to do next:
    1.- In one page 1 the result of web service method 1, (customer list) with option to select one of them and view his orders (page 2).
    2.- Page 2. list of customer's orders (result of web service method 2). This method should be called from page 1, with parameter = customer id selected.
    I have Web service data control, buit page 1 and page 2 (OK), but I dont know how to link and pass customer id parameter to invoke web service method 2...
    Any idea, help?
    Thanks.

  • Call SAPGUI transaction from BSP and vice versa

    Hi all
    There was some discussion about this topics before. Maybe someone can just point me to the thread answering this issue:
    1. I need to call a SAPGUI transaction from a BSP application: I want to use SAPGUI, not ITS/webgui, I need single sign on, the SAPGUI transaction could possible run in another SAP system then the BSP.
    As far as I understand I need to create a *.sap file with the correct parameters for sapshortcut. But how does single sign on work? Can I create a logon ticket in my BSP and forward it to sapshortcut?
    2. I need to call a BSP application from a SAPGUI transaction or report, with single sign on but in a MS IE window, not inside a SAPGUI HTML control
    Can I create a logon ticket in my coding an append it to the start url for the BSP?
    any hints?
    thanks
    Michael

    hi Michael,
    For your second issue,to call a BSP application from a SAP GUI in MS IE explorer,
    you can use the Function Module CALL_BROWSER in your report,like
    data url(200) type c.
    url = 'http://<server>.<domain><port>:'.
    concatenate url '/sap/bc/bsp/sap/' into url.
    concatenate url 'znw_poc2_1_prtl/dts.htm' into url.
    concatenate url '?sap-user=<userid>' into url.
    concatenate url '&sap-password=<passowrd>' into url.
    CALL FUNCTION 'CALL_BROWSER'
      EXPORTING
        URL                          = url
    *    WINDOW_NAME                  = ' '
    *    NEW_WINDOW                   = ' '
    *    BROWSER_TYPE                 =
    *    CONTEXTSTRING                =
    *  EXCEPTIONS
    *    FRONTEND_NOT_SUPPORTED       = 1
    *    FRONTEND_ERROR               = 2
    *    PROG_NOT_FOUND               = 3
    *    NO_BATCH                     = 4
    *    UNSPECIFIED_ERROR            = 5
    *    OTHERS                       = 6
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    For this to work you have to enable SSO on your server.
    you can check if it is enabled or not by runnning the BSP application "SYSTEM" ,page "SSO2TEST.htm" .
    Follow the instructions on the page for testing.
    This may not be a great way as your userid password are passed via URL,still it works .
    Hope this helps,
    Regards,
    Siddhartha

  • Get username from session and retrieve records from database wit tat userna

    hello..
    i got a ChangePassword.jsp which i retrieve the username from session using bean to display on e page..
    <jsp:getProperty name="UsernamePassword" property = "username"/>
    but in my servlet, i wan to retrieve records from database with tat username..
    i tot of coding
    String username = (String)request.getSession().getAttribute("UsernamePassword");
    and then use tat username to retrieve records.. but is that e right way? The page did not display and i got a CastingException..
    Please help.

    If you are using the session inside a jsp, you can say "session" without having to declare it.String usernamePassword = (String) session.getAttribute("usernamePassword");However, right after you get this value, check if it is null:
    if(usernamePassword==null)
    // do sth like forward to error page
    else
    // continue processing
    If it is null, then you are probably not setting it right in the first place. Make sure that in your servlet A you create a session, and before you return or forward to a jsp, that you actually set this value in the session like saying
    session.setAttribute("usernamePassword", usernamePassword);
    and it is case sensitive for the key.

  • Consistent calling of actions from JSP and code

    I have a question about opening up a JSP with a particular parameter (to set what we're looking at, for example).
    If I want to do it from a JSP, I can do something like this
    <af:commandLink text="Edit Scientist" action="editScientist">
    <f:param name="id" value="#{bbUserInfo.scientistId}"/>
    </af:commandLink>
    That follows the listed action, and sets #{param.id} to be the necessary value.
    If I want my action to be dynamic (using code from a bean), I can do this:
    JSFUtils.setRequestAttribute("id", scientistId);
    return "editScientist";
    (where JSFUtils is a class from various official tutorials).
    However, that sets #{requestScope.id} instead of #{param.id}. Is there a way of making these two calls consistent (for example, set the param.id from within the bean)?
    Regards,
    David C

    I have worked out one way to do this. I use this in the parameters section:
    <parameter id="sciId" value="${param.id == null ? requestScope.id : param.id}"/>
    And then I can reference bindings.sciId. Seems to work.
    David C

Maybe you are looking for

  • Working with after effects in photoshop?

    I want to edit some contents of the after effects of videos like clearning up skin or removing objects in photoshop from after effects  - how would this get done? both ar cs5 and both ar 64bit

  • File Adapter Wizard Step 4

    I'd like to write out a message variable to a file. When I use the file adapter, the wizard asks for a schema in step 4. There is no xsd schema defined for the message. I tried using the "Schema is Opaque" checkbox to create the partnerlink but then

  • How to display image through script

    Hi, In my template I am passing image path through xml, I need to display this image on XDP template. Please help for the same, I tried ImageField1.resolveNode("value.#image").href = "C:\\logo.jpg"; Image1.resolveNode("value.#image").url=".\logo.jpg"

  • Duplicated content with custom element

    Hello, I've created a new element named "news" and a PL/SQL procedure linked to it. When my element is displayed in a page, i've got 2 contents : - the first one is the content displayed normally by the portal (display name + text) - the second one i

  • Shuffle in the washing machine

    My shuffle got put in the washing machine by mistake. It was totally dead when it came out...is there any hope? Is there anything I can do to help revive it?