Can I use same result set for two queries?

Hi,
Can I use the same result set for two queries?
For example:
ResultSet rs = null;
rs = ps.executeQuery(query1);
while (rs.next()) {
rs = ps.executeQuery(query2);
while (rs.next()) {
Is it OK to use? or Is there any preformance issues?
Appreciate your help.
Thanks in advance.
Prasad Vagolu

Sure. You have a variable of ResultSet type. First you create a ResultSet and assign it to that variable. Then later you create another ResultSet and assign it to that same variable. Assigning an object reference to a variable takes essentially no time, and at any rate it isn't any faster to assign it to a different variable. Also, no matter whether you use one variable or two, you are still creating two ResultSets.
However, you really should be closing your ResultSets after you finish using them. That's nothing to do with the assigning-to-a-variable question.

Similar Messages

  • How to use same RESULT SET for two different events

    hello friends,
    I need to use same result set for two different events. How to do it.
    here My code,
    private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {
    // TODO add your handling code here:
    try
    String selstate,selitem;
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con=DriverManager.getConnection("jdbc:odbc:tourismdatasource","sa","");
    selstate="select * from tab_places where state=?";
    PreparedStatement ps=con.prepareStatement(selstate);
    ps.setString(1, jComboBox1.getSelectedItem().toString().trim());
    ResultSet rs=ps.executeQuery();
    if(rs.next())
    jTextField1.setText(rs.getString("place_ID"));
    jTextField2.setText(rs.getString("place_name"));
    jTextField3.setText(rs.getString("category"));
    byte[] ba;
    ba=rs.getBytes("image");
    ImageIcon ic = new ImageIcon(ba);
    jLabel6.setIcon(ic);
    in=true;
    catch(ClassNotFoundException cfe){JOptionPane.showMessageDialog(null, cfe.getMessage());}
    catch(SQLException sqe){JOptionPane.showMessageDialog(null,sqe.getMessage());}
    Now i need the same Result Set(rs), in another event(jButton6ActionPerformed),
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
    // TODO add your handling code here:
    }  how do i get dat resultset,
    help me out

    One post wasn't enough?
    {color:0000ff}http://forum.java.sun.com/thread.jspa?threadID=5246634{color}
    db

  • How can we use same material code for two different sales area

    Hello friendsu2026
    Hope you all doing well
    I am facing a problem and I will be thankful to all of you, for your suggestions
    Issue:
    I have a *material created in 3000/10/19 for domestic purpose *,now our company has decided to export it for that we have created a new sales are 3000/13/20 for export,we cannot create the salesa are as 3000/13/19 due to some  company issues,
    Is there any way how I can use the material already in 3000/10/19 into new sales area 3000/13/20.
    Will common distribution channel and division concept will be applicable here
    As the material is same,and we donu2019t want to go for any more new material code. *
    Thanks
    Siddharth Sharma

    Hi Sharma,
    when a material is used in domestic and exports.....i hope it should be seggreagated based on dist chnl.......but not division.
    because material is Division specific. it can be there in only one division. like mother child relation.
    that is the reason why...... it is maintained inside BASIC DATA...... but not in input screen while creating material master.[unlike dist chnl]
    because a material can be in multiple dist chnl....but not multiple division.
    I feel only alternative is creating new material if you are already decided to devide the sales by division for domestic and foriegn.
    Purpose of common dist chnl/div is to maintain pricing/condition in one common whenever you change master data.......
    hope this gives you the clarity
    regards
    Satya.SCM

  • Can I use same recovery disk for two identical computers?

    I own two PCs, model m8034n, which were identical when I bought them. If I order a Windows Vista recovery disk for one of them (specifying the serial number when I order), will I be able to use it to restore the other computer to its factory condition?

    I imagine as long as the Vista versions are the same on both computers it would be OK to use it.  No guarantee it will work but you may try.
    Please mark my post as SOLVED if it has resolved your problem. It helps others with similar situations.

  • HT204053 Can I use one Apple ID for two Apple IPhones?

    Can I use one Apple ID for two Apple IPhones? I received an answer of yes.
    Now another question.  I have one ICloud Account, Two IPhones.  Can I use Find my IPhone via the one ICloud Account?  Can I see two IPhones on the map at the same time?  or do I need to view the second phone via some other method.
    Message was edited by: Hunter3D

    Yes.
    Cheers,
    GB

  • Can we use same number range for different  fields

    can we use same number range for different  fields. how can we see the number range defined for a particular field

    Hai,
    Yes you can have same number range for different fields  by using the same domain to the data elements that are user to your two fields.
    To see the range:
    Go to SE11,Type table Name open it-->double click on the DataElement adjasent to the field name ,You will get Domian ,Double click on Domain You will get Domain.There See Value range option .Value range cam also be defined by Value Table which will also at the Doamin level.
    <b>Reward points if it helps you.</b>
    Regds,
    Rama.Pammi

  • Can I use one iCloud account for two phones without sharing contacts

    Can I use one iCloud account for two phones without sharing contacts

    If so how do I unmerge the two phones?

  • TS4268 i use my apple id that i create it for my iphone 4 on my new iphone 5,then i want to activate the imessage but i can't.what should i do?i want to know i can't use one apple id for two iphone 4 & 5?

    i use my apple id that i create it for my iphone 4 on my new iphone 5,then i want to activate the imessage but i can't.what should i do?i want to know i can't use one apple id for two iphone 4 &amp; 5?

    HI
    I was trying to take my Mac air to factory default settings.
    I've done all that it says in the documment i was following, and them during the process it asked me the APPLE ID.
    I put the apple id i have in my iphone. But it's not the one... it's said that i don't have any OSX associated with it... so it can not install the OSX.
    So what can i do?

  • Can we use same Business Service for Sender and Receiver

    Can we use same Business Service for Sender and Receiver

    Hi
    In addition to the above infomation explaining about the Business Service..
    Business Service: Address an abstract business entity as the sender or receiver of messages.
    Using a business service, you can define the technical or business subunits of the companies involved and then assign them the relevant interfaces.
    The business services are used when configuring cross-company processes also..
    regards
    Kishore

  • Can I use same apple ID on two IPads? And how do I name new IPad..Thank you in advance for any help

    Can I use same Apple ID on my old and my new IPad....and if so, how do I name the new iPad. want to keep games on one iPad and use the other for emails etc. Many thanks

    Hi,
    Yes you can definitely use the same Apple ID regardless of how many apple devices you have. This way you can install the apps that you have already purchased.
    It really does not matter what name your iPad is. You usually rename them under Settings>General>About>Name>
    Just a note if you use the same icloud apple id as well, both devices will recieve the imessages and facetime calls.
    Hope that helps!

  • Can I use one gift card for two apple ID at the same time?

    Can I activate one gift card for two different apple ID and use amount from gift card like bank account?

    No, an iTunes gift card can only be redeemed onto one account, and it can be used to buy content for that account (you can't, for example, redeem it on an account and then use some of it for gifting content to another account).

  • Find My Phone - can I use same user + password for 2 phones?

    Just loaded the "Find My Phone" App on my new iPhone 4 and set it up. What a great tool for locating a lost iPhone. The only problem is that my wife and I have a joint mail and apple ID account.
    So, my question is can I use Same user name (mail account) and password for TWO iPhone 4's (mine and wifes)? I assume that would work since each phone has a different serial number, and it seems to be ok when connected to my computer to sync each phone separately.
    Any help would be appreciated, thanks.

    My phone was stolen a few days ago. It must be flat by now, I have had it locked by my service provider, Find my Phone still works but says it's in Sydney, I live in Melbourne. Is this accurate? How can it still find the phone if it's not on?

  • Issues of using same enhancement set for different components

    Hi experts,
    I have an issue when using the same enhancement set(ZCRM_EHSET) for two different components IUICMD & IUICMRD. Component IUICMRD has two views IUICMRD/MainVS & IUICMRD/MeterReading and these views have been copied to Component IUICMD.
    Now, i am getting the following error, when i try to access AccountSearch view of component IUICMD
    Context initialization failed in view IUICMRD/MeterReading of UI Component IUICMD
    An exception has occurredException Class CX_SY_MOVE_CAST_ERROR - Source type \CLASS=CL_IUICMD_BSPWDCOMPONENT_IMPL is not compatible, for the purposes of assignment, with target type \CLASS=CL_IUICMRD_BSPWDCOMPONENT_IMPL
    Method: CL_IUICMRD_METERREADING_IMPL=>DO_INIT_CONTEXT
    Source Text Row: 10
    Let me know how i can solve this. Is there any precautions that i should have taken before using the same enhancement view for two different components.
    Thanks in advance.......................
    Regards,
    Prabahar

    Hi Bharathy,
    Thank you for the reply which helped me to come close to the solution.
    I hope you reply will solve the second part of my question where i get MOVE_CAST_ERROR.
    My first Question is still unanswered and i request you to provide solution if you have any. I worked on CRM 4.0 and CRM 2007 is new to me.
    My first question is below.
    I have two components IUICMD & IUICMRD. I have enhanced 4 views in the first component IUICMD using enhancement set ZCRM_ENHSET. There is no problem with that. But when i try to use the same enhancement set ZCRM_ENHSET for enhancing the second component IUICMRD, it's enhanceable in enhancement set.  But 2 views IUICRMD/Meterreading & IUICMRD/MainVS is also copied to first component and available as enhanceable views in First component.
    Is it the std behaviour that views from one component is copied to other when you try to use the same enhancement set? Kindly let me know if you faced similar situation.
    Best regards,
    Prabahar

  • How to use same jco destinations for two DCS

    Hi,
        I have a scenario where two dcs are using the same function module so i have a doubt that can we make jco destinations different for two dcs or not,plz help me
    Thanks,
    Santhosh.

    Vanama
    JCO Destination names are associated with models and not DCs. You can use same or different JCO destination names across different models.
    Typically if you are using a common set of function modules(RFCs) you might decide to create one or more model (each model consisting of logically related RFCs)in one DC and use it accross different DCs(By declaring the usage of the DC in other DC and declaring model usage in a particular component). This not only will save build time during design process, but will also bring in modularity and reusability. But its purely a design decision you need to make based on your requirement.
    kk

  • Same rule set for two apply processes

    Hi!
    Can anyone tell me whether it is possible to use the same rule set and all rules in it for two apply processes? It would be easy for me to use such configuration, because sometimes I create LCRs myself, sometimes Oracle captures them. They're exactly the same.
    And second question - I tried the above configuration, but the apply process for user created LCRs aborts when it sees first message. Error is: "ORA-00600: internal error code, arguments: [knlcfpactx:any_knlso], [], [], [], [], [], [], []". Oracle MetaLink and Google know nothing about this error. I also don't know if it's somehow connected with these rule sets or is it a problem within my procedure which creates LCRs.
    Greetings

    I'm answering myself. Yes, it is possible, to use the same rule set for different processes. It is said in the documentation. It is also possible to use one rule in several rule sets according to documentation.
    And it seems that it has nothing to do with my ORA-00600 error.

Maybe you are looking for

  • One database with multiple instance names

    Dear all, We would be very happy if anyone can provide me with some information of how RMAN operates. Current situation: we have 2 machines running Oracle9i with just one database. The production database is "replicated" using EMC's TimeFinder/Snap.

  • Is Safari and Firefox for Mac not supported on SAP Interactive Forms by Adobe?

    Are Mac OS X browsers like Mozilla Firefox and Safari not supported by SAP EHP3 NetWeaver 7.0?  If not, are there any alternatives?  I find it hard to believe that Mac users won't be able to transact on SAP's interactive forms by Adobe.

  • Wireless speed inside the house

    I have E4200 router. My house has cable connection of 30mbps. That is the speed that data comes to my modem interface. Does the modem waits until it receives all the packets from outside until it starts passing it off to router or it passes it as it

  • Removing unwanted chapter markers from m2v files

    I inadvertantly left some unwanted chapter markers in FC sequences which I then exported as m2v files. Is there any way to remove the chapter markers from the m2v files so I don't have to re-render to m2v? I have lots of files!

  • Error while transferring Business Partner

    Hi, When i go to BBPMAINTINT in SRM and try to transfer Business partner from SUS to SRM as vendor, i am choosing the SUS supplier directory and vendor and i selected the accepted supplier and clicked on transfer. Now i am getting an error message "