"Overlapping ResultSets" from one Statement Object

I'm using Hypersonic database and retrieving data using JDBC.
I create a single Statement object which I use to return multiple ResultSets.
e.g.
conn = DriverManager.getConnection(url.getText(), "sa", "p");
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
customerRS = stmt.executeQuery(sql1);
productRS = stmt.executeQuery(sql2);
If use the second ResultSet before the first has been fully traversed, I loose the data in the first.
This comes about because I'm changing a DefaultTableModel from reading the ResultSet into an array to pulling the data out of the ResultSet in the getValueAt as and when required.
I have multiple jtables in my app, when I pulled all the data out of the ResultSet into an array and then returned the array values on the getValueAt(), every thing was fine, now I try and have the ResultSet hang around, I'm getting "empty" tables displayed in my app.
So, my question, do I need a Statement object for every RecordSet I want to access in this way or is there a bug in the JDBC driver I am using ?
regards,
dave

First, I believe the problem you are experiencing is in the OBDC:JDBC bridge. If you are using Hypersonic drivers, you might look at upgrading.
If the driver will allow it, you can actually return multiple resultsets.
http://search.java.sun.com/search/java/index.jsp?qp=&nh=10&qt=%2B%22multiple+resultsets%22&col=javaforums

Similar Messages

  • Error: The report source could not be retrieved from the state object.

    I have been trying to create a report in a JSF page. The relevant parts are below:
    Inside the JSP page, this is the code:
                  <jsp:useBean id="MyBean" class="com.nm.facade.rto.POJOViewerBean" scope="session" />
                    <jsp:setProperty name="MyBean" property="reportLocation" value="Report1.rpt" />
                   <v:reportPageViewer reportSource="#{MyBean.reportSource}"
                                           displayToolbarPrintButton="true"
                                           printMode="ActiveX"
                                           zoomPercentage="100"
                                           displayToolbarExportButton="true"
                                           displayToolbarRefreshButton="true"
                                           viewerName="My Viewer"
                   ></v:reportPageViewer>
    In the backing bean, this is the relevant code:
        public Object getReportSource() throws ReportSDKException
            if (propertiesChanged || reportSource == null)
                propertiesChanged = false;
                if (reportLocation == null)
                    throw new RuntimeException("The reportLocation property must be set before a report source is retrieved");
                ReportClientDocument rcd = new ReportClientDocument();
                rcd.setReportAppServer(ReportClientDocument.inprocConnectionString);
                rcd.open(reportLocation, 0);
                DatabaseController dbc = rcd.getDatabaseController();
                //Create the POJO collection and populate it with data
                ReportData[] data =
                  new ReportData("B.B.", "King", 6, new Date(25, 9, 16)),
                    new ReportData("Muddy", "Waters", 7, new Date(15, 4, 4)),
                    new ReportData("John Lee", "Hooker", 8, new Date(16, 8, 16)),
                    new ReportData("Otis", "Rush", 9, new Date(34, 4, 29)),
                    new ReportData("Buddy", "Guy", 10, new Date(36, 7, 30))
                //Create the result set from the collection of POJOs
                POJOResultSetFactory factory = new POJOResultSetFactory(ReportData.class);
                factory.setVerbose(true);
                POJOResultSet results = factory.createResultSet(data);
                ResultSetMetaData metaData = results.getMetaData();
                //Set the resultset as the report datasource
                      //Get the table name from the 'Set Datasource Location' dialog in the Crystal Reports designer
                String reportTable = "getReportDataDataSource";
                dbc.setDataSource(results, reportTable, reportTable);       
                IReportSource reportSource = rcd.getReportSource();
                if (reportSource == null)
                    throw new RuntimeException("Unable to get a report source.");
            return reportSource;
    In the CRConfig.xml, this is what is there:
    <?xml version="1.0" encoding="utf-8"?>
    <CrystalReportEngine-configuration>
        <reportlocation>../reports</reportlocation>
        <timeout>0</timeout>
        <ExternalFunctionLibraryClassNames>
             <classname></classname>
        </ExternalFunctionLibraryClassNames>
    </CrystalReportEngine-configuration>
    The report template 'Report1.rpt' is packaged under WEB-INF/reports in the war file.
    When I try to generate the report by accessing the JSF page, I am getting an error: "The report source could not be retrieved from the state object. "
    I am not sure what is wrong. Can someone help me in resolving this issue?
    Edited by: renshai on Jul 9, 2009 3:21 AM

    My formatting gets lost and the message looks unintelligible. After some experimentation, I found that if the message exceeds some length, the formatting is removed. Since I couldn't find any way to delete this post, I made another post with the same subject. Please ignore this post and help me to find a solution for the problem posted in the other thread with the same subject. Thanks in advance.

  • Troubles in copying a VGroup from one state to another

    Hey there!
    I am trying to build an application where the user can select whatever he wants to appear in his homepage. The user is given a list of checkboxes (with a corresponding label and image to every checkbox). I have kept all three of these items in a Vgroup and now I want to move this Vgroup from one state to another IF the checkBox is selected. Here is my code:
    protected function btn_done_clickHandler(event:MouseEvent):void
                    if (chkbox1.selected == true) {
                        this.group1.currentState = "MainWindow"
                    else if (chkbox1.selected == false) {
                        this.group1.currentState = "AddPeople";
                    this.currentState="MainWindow";
    This code does not show any errors before running but it crashes when this program is run. And it also show the following error report:
    ArgumentError: Undefined state 'MainWindow'
    Can someone please help to identify what I am doing wrong here?

    stmt.executeUpdate("INSERT INTO TABLEA(id,field2,field3,field4) SELECT id + " + x + ",field2,field3,field4 FROM TABLEB  WHERE UPLOADNUM="+upnum);  Where x is the number you have already calculated.
    Ted.

  • How to return ResultSet from one function to another?

    Hi friends,
    Greetings.
    How do we pass the query Results from one function to another function?
    Actually i have a database in the server and i am the client.
    Client sends the id to the server as an argument. From HTML file this goes to the JSP file(which i am using as a link between HTML and EJB) and then this goes to the RemoteInterface and then to the Bean itself. The functions are written in the bean. Bean connects to the database using jdbc:odbc driver and then a query is written and executed as follows:
    In the Stateless Session Bean, there is one function with the following query.
    public ResultSet check(String id)
    //other code
    ResultSet rs = Statement.("select * from table1 where id=123");
    if(!rs.next)
    // print no such id exists. other ids are
    rs=Statement.("select * from table1");
    return rs;
    I have written it approximately only because the problem is not with the query :(
    Now, in rs there's a resultset. Now how do i display it in a tabular format in HTML? This should obviously be done using JSP. How can we do it?
    In JSP file if i write
    ResultSet rs1=Remote.check(12);
    i get NullPointerException
    Thank you in anticipation to your reply!
    Regards

    Crossposted over all places:
    [http://forums.sun.com/thread.jspa?threadID=5336533]
    [http://forums.sun.com/thread.jspa?threadID=5336534]
    [http://forums.sun.com/thread.jspa?threadID=5336532]
    [http://forums.sun.com/thread.jspa?threadID=5336519]
    [http://forums.sun.com/thread.jspa?threadID=5336510]
    Stop crossposting. It's very rude.

  • Move child movie clip from one parent object to another

    Hi everyone,
    I am somewhat new to AS3, and I'm having a hard time working out the most appropriate way to move a child movieclip between parent objects.
    I'm creating a board-game type game wherein I've dynamically created an array of 'Square' movieclips, with no visual elements, which are arranged in a 10x10 rectangle on the stage. I then dynamically add the appropriate types of piece movieclips to the various squares with the addChild() method. In general, a square should only have one child piece at a time.
    All of this works well for setting up the play area, but now I'm having an issue with moving a piece from one square to another. I want to have the user click a square with a piece on it, then click the destination square to move the piece. I have the logic for determining where a user can move any given piece to, but I don't know how to actually move the piece.
    The pieces are all different class objects that extend both a base class I call Piece as well as the MovieClip class. The main issue is that when dynamically adding the various pieces to the squares, I don't provide them a unique name to access them later. I don't bother with unique names because I have no way of knowing which piece instance will be in a given square, so using getChildByName(name:String) isn't very useful.
    So I can think of two routes that I can take: Making a getter/setter for the Square class that manages a private Piece property (as well as the adding and removing of the child piece to/from the parent square), or using getChildAt(index:int) to try to access the child piece.
    I want to go with the first route as it seems to be the most maintainable to me. My problem is that I can't work out how to manage empty squares in this scenario. My instinct is to null to private _piece property of one square once I've moved the child piece instance to another square... but I'm fairly certain that the private property is a reference type, and nulling it out will null the actual piece object even after it's changed parents.
    I'm sorry for the long description. I'm hoping that my lack of experience with as3 it what's causing my trouble, and that someone more well versed will know of the best way to handle this. Maybe I'm overthinking everything.
    If something isn't clear, please feel free to ask me for clarification. I would appeciate any help that anyone may be able to offer.
    Thanks!
    - Scott

    for a square with a child, you can use:
    whateversquare.getChildAt(0);  // to reference whateversquare's only child.  although, if there are graphics in whateversquare, you may need to use getChildAt(1)
    or, if you want to use a square class getter/setter, what's the problem?  an empty square will return null.

  • Copy reports from one business objects server to another

    How do I copy all the reports published in my production BO server to my test server. I did this once but can not remember. Is it the import wizzard?

    yes you can use the import wizard to export your reports from one server to another server
    just open the import wizard, connect to your source server, choose object types you want to export (folders, reports, users,,,,etc),,, then choose the objects itself, then connect to the destination server, and the import wizard will guide you through this process.
    good luck

  • How to lod Hierarchy from one info object to anothe info object

    Dear Friends,
    I am facing one problem with the loading of hierarchy from one object to another.
    Please find my scenario below.
    We are having 0material with hierarchy.This hierarchy is loading from R/3.We have to load this hierarchy to anothe object by replacing the nodes.So can you guys please suggest how to achieve this.Please let me know if you people are required additional information.
    Thanks in advance.
    Regards
    Madhu

    Hi Madhu,
    By default, you cant use a transformation to load data into the Hierarchy Master data.
    I havent tried it myself, but for you to explore, I'll suggest the below idea.
    Write an ABAP program to download the hierarchy table data from 0material into a flat file.
    Create flat file datasource to upload hierarchy to the other infoobject.
    Put both of them in a process chain and execute one after another.
    Hope this helps. Pls let us know.
    Regards,
    Bijesh

  • Passing ResultSet from one function to another

    Hi friends,
    Greetings.
    I am a beginner in Java.
    I am doing an exercise using jdbc:odbc driver where i have to query the database in one function and pass the ResultSet to another function.
    Let function1 be
    ResultSet select(String sel) // sel is the id of what is to be selected { Resultset rs= //coding return rs; }
    Let function2 be
    function2 { String id="abc"; ResultSet rs1=select(id); //code to print rs1 }
    Is my code correct? i get a NullPointerException always.
    Please help
    Regards.

    rampalli_aravind wrote:
    Thanks a ton for the reply!
    Well,
    how do i pass the query Results?
    Actually i have a database in the server and i am the client.
    Client sends the id to the server. Server processes. finds the id and returns the name and other details using SQL statement:
    select * from table1 where id="abc";Server should return these details back to the client.
    IF no such id exists then server should send the client the following result:
    //print that the given id does not exist and these are the ids and names in table1
    select * from table1;How can i do it using jdbc odbc driver?
    Thank you in anticipation to your reply!
    Regardssee my reply to your other post.
    write a server side component that opens the connection to the database, loads the ResultSet into a data structure, closes the ResultSet, and returns the data structure to the client.
    the client should not be dealing directly with the database.
    %

  • Creating 2 dataproviders from one remote object

    Hello,
    I have created a remote object that populates an
    arrayCollection to be used as a dataprovider for a pulldown menu
    item. In one instance I want to append data to the dataProvider to
    show an additional item in the list and in the other dataProvider I
    just want the data returned from the Remote call. The problem is
    that when I add the additional item to the list it is also
    reflected in the second arrayCollection. How can I use one remote
    call to populate 2 separate arraycollections and not have changes
    made to one of the collections reflected in the other?

    Not quite... What I have is one datacall the populates two
    different arrayCollections that are dataproviders. In one of the
    arrayCollections I'm adding an additional element (i.e. Show All),
    but in the other array collection I don't want the additional
    option to be visible. When I add the additional element to the
    first arrayCollection it modifies the second arrayCollection .
    Here's my code (short hand):
    [Bindable] array1:ArrayCollection = new ArrayCollection();
    [Bindable] array2:ArrayCollection = new ArrayCollection();
    private function getData():void{
    ----Code to get data from server here
    ----call to function to handle result();
    private function handleResult(e:ResultEvent):void{
    array1 = e.ResultEvent as ArrayCollection;
    array1.addItemAt("Show All", 0);
    array2 = e.ResultEvent as ArrayCollection;
    When I add the item to array1 it is also reflected in array2
    and I don't want this as these ACs are used to populate pulldown
    menus. Hope this helps to clarify...

  • More thn one statement object on connecton

    iam trying to use two prepared statements on one onnection,
    for doing two updates. Do i need to close the statment before
    invlking a new statement. Iam also commiting or rolling back from
    these two processes with the same connection. Is it ok
    if i close both statements in the end in 'finally'

    iam trying to use two prepared statements on one
    onnection,
    for doing two updates. Do i need to close the statment
    before
    invlking a new statement. Read the docs for Statement and PreparedStateement. If it doesn't explicitly tell you one way or the other, then be safe and explicitly close the first before opening the second.
    Iam also commiting or
    rolling back from
    these two processes with the same connection. Is it ok
    if i close both statements in the end in 'finally'You want the close in a finally block. However, depening on the results of your investigation, you'll either have one try/catch/finally statement that encompasses both statements, or you'll have two separate ones.

  • Copy object from one authorization object classe to another one

    Hello experts,
    due our revision we have the demand to copy our custom context sensitve authorization object from the old authorization class to a new one.
    Ist this generally possible? What are the impacts?
    Any ideas?
    Many Thanks!
    Marco

    > due our revision we have the demand to copy our custom context sensitve authorization object from the old authorization class to a new one.
    That is a strange revision (audit) demand... Did you challenge them whether they have ever done this before and survived as release upgrade?
    Is SAP_ALL otherwise okay for them? For example that people can write their own programs or maintain PRGN_CUST to include Z-classes again...
    Have you tried to simply remove all profile assignments to SAP_ALL and replace them with proper roles and restrict SAP*'s HR profiles to that which applies to all users which are not employees?
    You are definately barking up the wrong tree here by moving SAP objects to Z object classes and expecting it to be secure...
    Cheers,
    Julius

  • Automatic transition from one state to another

    I am newbie to Cat and I have a simple three state (page) project and I just need it to automatically go from state 1 to state 2 to state 3 and then repeat the squence again.  This is a banner ad for three differenct products.
    The question: How do I setup an automatic transition from state to state?

    Hi,
    Thanks a lot. Even I am a newbie like u to Flash catalyst. The solution u gave works only when we have 2 pages. I have 6 pages (states) in my application. So please let me know if u come across any other solution.
    Thanks a lot for ur help.

  • Loading Hierarchy from one info object to another

    Hello friends,
    I have Profit Center Managerial Hierarchy which is connected to R3 QAS.  It is in the infoobject 0PROFIT_CTR.  I want to load the same Hierarchy from 0PROFIT_CTR to BCS info object 0BCS_PRCTR.  Is there  any way to do it.
    Thanks
    Jose

    Hi Jose,
    It's easier to load a new IO from the same datasource in R/3, not from 0PROFIT_CTR.
    Best regards,
    Eugene

  • Please, Not getting result set from callable statement (Code posted)

    I am posting some simple code which should get a ResultSet from a CallableStatement object using the executeQuery() Method.
    It is returning "No RsultSet was produced"
    If I modify the code and simply output the CallableableStatement using its executeUpdate() then getString() methods it works fine. Anything obviously wrong with this bit of code? Thanks.
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.sql.*;
    import db.util.query.*;
    import db.util.pool.*;
    public class oracle extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, java.io.IOException {
    response.setContentType("text/html");
    java.io.PrintWriter out = response.getWriter();
    Connection con = ConnectionFactory.getConnection();
    CallableStatement cs = null;
    ResultSet rs = null;
    int intID = 1;
    try{
    cs = con.prepareCall("{? = call test1(?)}");
    cs.registerOutParameter(1, java.sql.Types.VARCHAR);
    cs.setInt(2,intID);
    /*These lines work on their own
    *cs.executeUpdate();
    *out.println("Name is : " + cs.getString(1));
    //this code is what is not working...hmm
    rs = cs.executeQuery();
    while(rs.next()){
    out.println(rs.getString("name"));
    rs.close();
    cs.close();
    //the rest of this works too.
    ConnectionFactory.releaseConnection(con);
    catch(SQLException e){
    out.println(e.getMessage());
    Here's the stored procedure. I'm just trying to do a simple test to return multiple rows. The table has numberous records with the same id which is being passed to the function.
    create or replace function test1 ( strInputID IN testtable.id%type)
    return varchar2
    is
    strOutputName testtable.name%type;
    found_it EXCEPTION;
    begin
    select name into strOutputName from testtable
    where id = strInputID;
    raise found_it;
    exception
    when no_data_found
    then
    return null;
    when found_it
    then
    return strOutputName;
    end;

    I've posted the code...it's doing a select. I think the problem is that to return multiple rows I need to return a cursor. But I've run into problems with both the MS and Oracle Drivers.
    All I really want to do is to query a database using a callable statement(function in oracle) which will return multiple rows which I can process. I have been trying to do this in a servlet.
    I can do it successfully for one column from one row, but not multiple columns from mulitple rows.
    I've been searchging for some good examples and am trying different things but can't seem to get it to work.

  • Running two stepper motors at the same time from one port

    Hello,
    I have to run two motors at the same time - one used to move a linear ball screw and one to turn a grip. I am doing tension and torsion testing on small wires, but tension and torsion have to be done at the same time. I also have to build in the ability for each motor to take multiple steps, ie. have a motor take x number steps at y velocity and then move x number of steps at z velocity. Both motors need to be able to do this. However, I am having problems getting the motors to run at the same time and to take all the steps. The motors are connected to two RMS Technologies R356 controllers. Both of the controllers are then connected to one RS485 to USB converter card, and that card is connected to one of the USB ports in the computer. Currently, I pass an array of commands to two for loops each containing VISA read and writes. I've attached the vi to look at. All of the timing stuff in the code is because a new command cannot be sent to the controller before the motor is done executing the previous command. If commands are sent right after one another, the controller will only execute the first command and then return with an error. 
    Does anyone have a suggestion as to what I am doing wrong?
    Thanks in advance for any help. 
    Solved!
    Go to Solution.
    Attachments:
    Motor Controller (Sub VI 3).vi ‏41 KB

    I'm not too clear on exactly what you are trying to accomplish or some of the details.
    Are there equal number of torsion and tension steps?
    Is there a pairing between a torsion and tension?  For example, you want to tension and torsion simultaneously, but those two together make a complete step?
    Do you want to wait until both the torsion and tension have completed before moving on to the next torsion/tension pair?
    Is there any time delay you want to hold at before moving on to the next step.
    When working with state machines, it is important not only to define the states, but also the logical stepping from one state to the next, or alternatives based on conditions.  It could be flowchard, but sometimes people call them state charts.
    Right now your latest posting has goes to "Write to Motor" event though and will wait there forever because there is nothing in the queue to write out through the VISA port.
    Let's assume your first state would happen to be Enqueue Tension (in order to get something in the queue), you will actually queue up all your tension commands at once with the For loop.  Then i will be 1 less than the size of the array it always will be because for an array size n, i will go from 0 to n-1 on each iteration.  So your false case will run and you will go to "Write to Motor".  Write to Motor will run and dequeue the first command then go to Waiting for Response.  Waiting for response will iterate through the while loop until 66 or 67 comes back.  I assume only 66 will come back for tension since you have yet to write a torsion command.  Once that comes back, it will go to Enqueue Tension again and insert a whole other series of commands.  Then go back to write Motor and will take out the 2nd queue element from the first set of commands your wrote.  It will stay in a Tension mode and the Queue will grow endlessly putting in a whole new series for each element that you dequeue.
    A state machine is the way to go, but I can't really sketch one out for you because I'm not sure exactly how your applications is supposed to work.  If a tension and torsion command are paired together,  perhaps you should just queue them together and write them out at once.   But the key thing is to sketch out on paper your application and flowchart exactly how the program should progress from step to step.
    PS:  One other thing, make sure you wire the queue reference wire through all states.

Maybe you are looking for

  • Images are pixelated

    All the photos that I open in Photoshop lose their quality and appear pixelted, in comparsion to when i open and edit photos in digital photo professional. Please help me The camera used is a Canon rebel t3, and I shoot most photos in Raw, however i

  • Apple account set up

    My girlfriend's son just received an new iPod Touch for Christmas, and can't set up an account. He keeps getting a message saying that he doesn't meet the minimum age requirement.  But according to other discussions, this has happened to people as ol

  • An Apple ID blocks my Apple ID

    Many years ago I made an Apple ID with my current e-mail. When I needed it again I could not get the password. I made a new Apple ID which I use now with the e-mail at work. This works fine, except that my e-mail at home is blocked from my new Apple

  • Upgrading my Macbook to Lion

    I have a 13" Macbook, bought in late 2006 which is still running Tiger. I have been looking into options for upgrading the OS for a while now. I have Snow Leopard running on another Mac, so have the disc, but found that I could not upgrade from Tiger

  • Setting a Trasparent Color?

    Hey folks, Im working with Keynote for the first time this evening and as a long term Window's user I am having a bit of a hard time transitioning. I am looking for a feature in Keynote that allows me to set a transparent color on an image (similar t