How to run two query  in the same preparedStatement

Hi all,
Please tell me how to run two queries in the same preparedStatement object ?
In my module I have to run two queries and I don't want to make two methods for running two different queries.
I just want to call this method for both of my queries.
methodName(long param)
Connection conn=null;
PreparedStatement pstmt=null;
//////////////// some coding
Please Help !
Thanks in advance
amitindia

    public void foo()
        Connection connection = null;
        PreparedStatement stmt = null;
        try {
            connection = ...get from pool...;
            stmt = connection.prepareStatement("...");
            ...fetch results...;
            stmt.close();
            stmt = null; // So the finally statement works if there is an exception
            stmt = connection.prepareStatement("...");
            ...fetch results...;
        } finally {
            if (stmt != null) ..close it...;
            if (connection != null) ..return it to pool...;
    }

Similar Messages

  • How to run two icalenders on the same computer?

    How can i run two separate icalenders on the same computer? I have my own icalender with work, home, etc, and it's totally full. I am now running an artists collective and will publish the collectives icalender on the web. I don't, however, want to mix what will be a pretty busy calender with my own already too full one. Is it possible to run two totally separate calenders on the same computer?
    macbook   Mac OS X (10.4.8)  

    trsv,
    Welcome to Apple Discussions.
    Create two Groups...
    Calendar 1:
    Work
    Home
    etc
    Calendar 2:
    Collective Calendar
    You can then switch which groups you wish to display by activating/deactivating the check mark in the Calendar source window.
    That will also allow you to selectively publish the Collective Calendar.
    ;~)

  • Run two VIs at the same time

    Hello!
    I want to know how i can run two VIs at the same time.
    I mean that i want to run a second VI ( N.2) while another VI (N.1) is in
    execution without suspend it (N.1)
    If anyone has suggestions, please help me!
    Thank you very much.
    roby.

    If you say "run a vi", I assume that you have the VI open in LabVIEW, then press the run button. (Some of the earlier answers taks about programmatically calling VIs, which I don't think is the focus of your question)
    You can run as many VIs as you want at the same time. Simply press the run button of the second VI and they will both run.
    Of course you should ensure that they don't use the same resources (e.g. DAQ device, or listen on the same TCP port, etc.) In these cases, the second VI might fail. (Also if the second VI is a subVI of the first VI, you won't be able to run it seperately, because it will be already running.)
    LabVIEW Champion . Do more with less code and in less time .

  • Can I run two PIDs from the same vi?

    Hi
    I want to control speed of the rotating shaft and force applied by the pneumatic cylinder using two different PIDs from the same program.
    I managed to get two PIDs to work separatly using PID control loop VI`s supplied with labview 6.1 (I got Kc, I and D right, so there is no overshoot). When I try to run both PIDs within my vi they don`t work. I again tried various gains and managed to get one PID to work but not the other. Then through trial and error I managed to get a second PID to work but I had to change refresh time of the FOR loop from 100msec to 1msec.
    Does anyone have experience with running two PIDs in the same program? Does the timing of the FOR loop influence PID contorller? Does equiring of other data while run
    ning PID has effect on the PID?
    I would really appreciate any comments/help. I am pretty thrustrated at this time
    Thanks"

    The timing of the FOR loop will influence your PID control, which is a fundamental part of PID control. Acquiring data doesn't affect the PID although it could affect the timing of the loops. For instance if you only have one DAQ card you would want to have it all in one loop because you can not have two AI sessions open to the same card.
    For more detailed information on PID I would recommend reading the "PID Control Toolset
    User Manual" which should have been installed to your machine but can also be found at : PID Control Toolset User Manual"
    Regards,
    JR A.
    Application Engineer
    National Instruments

  • Can i run two PIDs at the same time?

    Hi
    I want to control speed of the rotating shaft and force applied by the pneumatic cylinder using two different PIDs from the same program.
    I managed to get two PIDs to work separatly using PID control loop VI`s supplied with labview 6.1 (I got Kc, I and D right, so there is no overshoot). When I try to run both PIDs within my vi they don`t work. I again tried various gains and managed to get one PID to work but not the other. Then through trial and error I managed to get a second PID to work but I had to change refresh time of the FOR loop from 100msec to 1msec.
    Does anyone have experience with running two PIDs in the same program? Does the timing of the FOR loop influence PID contorller? Does equiring of other data while
    running PID has effect on the PID?
    I would really appreciate any comments/help. I am pretty thrustrated at this time
    Thanks

    I don't know whcih PID vi's you are using but I had similar problems. I
    solved it by going to the VI properties of the PID subvi, select category
    execution and make sure that reentrant execution is selected. Only then two
    instances of the PID vi can run without interfering each other.
    Martien
    solved by setting the execution mode
    "smartlander" wrote in message
    news:[email protected]..
    > Hi
    >
    > I want to control speed of the rotating shaft and force applied by the
    > pneumatic cylinder using two different PIDs from the same program.
    > I managed to get two PIDs to work separatly using PID control loop
    > VI`s supplied with labview 6.1 (I got Kc, I and D right, so there is
    > no overshoot). When I try to run
    both PIDs within my vi they don`t
    > work. I again tried various gains and managed to get one PID to work
    > but not the other. Then through trial and error I managed to get a
    > second PID to work but I had to change refresh time of the FOR loop
    > from 100msec to 1msec.
    > Does anyone have experience with running two PIDs in the same program?
    > Does the timing of the FOR loop influence PID contorller? Does
    > equiring of other data while running PID has effect on the PID?
    > I would really appreciate any comments/help. I am pretty thrustrated
    > at this time
    > Thanks

  • How to get two parameters in the same line of selection screen?

    hello
    i need to get my selection csreen like bellow.
    r1 radiobuttion  -some space --p1 parameter
    i should not get the parameter in the next line of  radiobuttion.
    how to get two parameters in the same line of selection screen?

    hi....
    modify the following code
    it will work
    SELECTION-SCREEN BEGIN OF BLOCK SL1 WITH FRAME TITLE TEXT-003.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 10(15) TEXT-001
                     FOR FIELD P1.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS : P1 TYPE   C USER-COMMAND R2 RADIOBUTTON GROUP R2 DEFAULT 'X',
      P2 TYPE SCARR-CARRNAME,
      P3 TYPE CHAR1 RADIOBUTTON GROUP R2.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK SL1.

  • HOW TO PUT TWO PANNEL IN THE SAME PAGE

    HI ALL
    I NEED TO KNOW HOW TO PUT TWO PANNEL IN THE SAME PAGE TO FULLY UTILIZE FULL PAGE AREA BECAUSE THE PANNEL WIDTH IS TOO SMALL , SO I WANT TO MAKE THE PAPER CONTAIN TO PANNELS VERTICALLY.
    THANK YOU

    So Barb,
    I like to use multiple desktops and move back and forth between then using gestures. At the moment I have 5 open: Chrome, Firefox, Safari, Photoshop CS 6 and a desktop. I use "gestures" to navigate between them:
    Mac Basics: Multi-Touch gestures - Apple Support
    and I use Mission Control (F3) to move the various desktops around in the order I want them.
    Mac Basics: Mission Control - Apple Support
    So say I'm searching for a photo to open in CS 6, I find it on the open desktop then hit select "open" in CS 6 and go to that folder in the select pane.
    Even right now I'm typing this in Safari and "gesturing" back to Chrome where I did the search about multi touch and mission control. I drag copy the URL there  and gestured back here to paste the URL into this text.
    If you did a lot of photo searches, I set professional clients of mine in Chicago up with dual monitors (In this case you'd have an external monitor on extended desktop.). So all you need to do is just glance over at the second monitor slide your cursor over there open stuff up find your photo and go back to Photoshop and open it up.
    Hope this helps.

  • How to write two item in the same line?

    In the smartforms,how to write two item in the same line?
    eg
    1   *************                                    2  *****************
    3  **************                                   4  ******************
    5  ***************
    Anyone got any idea to do this.
    Thanks in advance

    Hi,
    In the smartform the main windows is 20cm.I use the table output my data.Because the output is two item in same line,I define two rows in the table line type.
    Question:
    Should I define the table width 20cm?
    In the main area of table , should I define two folders and each of folder include a line? The second item I had already defined as Append Directly,but the item 1 and item 2 don't in the same line.
    Regards

  • Can i run two widgets at the same time on the same page?

    Can i run two widgets at the same time on the same page?
    Hi
    I have created and published 4 free ibooks and i would to run two widgets
    - a countdown clock
    - a review test
    at the same time on the page. Can i do that?
    Thanks in advance
    Haris

    thanks for your answer. Yes indeed HTML widgets run only full screen (snif snif). I consider this as a "distinguishing treatment".
    One solution  i read !!!!! was to create through keynote a countdown clock, to export to quicktime move and to imported at iBA predefined widgets. of course this is not the solution i need.
    So, in order to have at the same widget and run together a count down clock and a preview test (20 questions)  i must
    1)"hack" the preview widget and insert a countdown clock
    2) create a preview test using iAD.....
    thanks again
    haris

  • How to insert  two queries in the same workbook in new BI 7.0 Bex web analy

    Hi
    Can you please advise how to insert multiple queries in the same workbook in BI 7.0 web analyser.
    Sarah

    Hi,
    You need to switch to design mode (BEx Analyser Menu - Design Toolbar - Design Mode). For each query that you want to embed, insert an analysis grid item in the workbook. Link each analysis grid to its corresponding data provider (query).
    Hope this helps.
    Regards,
    Rajkandula

  • How to put two files with the same name into the same folder?

    How can I put two files with the same name and the same extention into the same directory?
    Is this even possible?
    Thanks in advance. 

    Are you sure? I would be very surprised if that was the case.
    How does the computer/filing system differentiate the files, if not by their names?
    How do you tell the computer which one you want? (On the command line.)

  • Can I run two ipods from the same itunes library/account?

    I have a 20gb photo colour ipod and have just bought a new 30gb video ipod. I need to know whether I can run them off the same library and itunes account or do I have to have separate user accounts?
      Windows XP   iTunes 7.0.1.8

    Yes, you can.
    You can either have multiple user accouts on your computer, or create separate playlists for your two iPods in iTunes.
    This should explain how to manage multiple iPods:
    How to manage multiple iPods using one computer
    -Kylene

  • How to play two videos at the same time

    Hi everyone!
    Ok, so what I'm trying to do is basically play two videos, which are already saved on the computer, at the same time. I can get one video to play, but when i try to start another it just displays a blank screen.
    import javax.swing.*;
    import javax.media.*;
    import java.awt.*;
    import javax.media.protocol.*;
    public class TwoVideoTest {
         public static void main(String[]args) {
         MediaLocator locator1 = null;
         MediaLocator locator2 = null;
         try {
         locator1 = new MediaLocator("file:/C:/truck1.mpg");
         locator2 = new MediaLocator("file:/C:/truck2.mpg");
         } catch(Exception e) {
         System.out.println("COULNDT CREATE LOCATORS IN MAIN TEST CLASS");
                          System.exit(-1);
         Player player1 = null;
         Player player2 = null;
                     try {
          player1 = Manager.createRealizedPlayer(locator1);
         player2 = Manager.createRealizedPlayer(locator2);
                      } catch(Exception e) {
              System.exit(0);
         JFrame frame = new JFrame();
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel1 = new JPanel();
       JPanel panel2 = new JPanel();
        panel1.add(player1.getVisualComponent());
       frame.getContentPane().add(panel1);
       frame.setSize(new Dimension(500,500));     
       frame.setVisible(true);
       player1.start();
       player2.start();
    }

    HELLO AGAIN! I guess i post too soon....
    So i modified my code and now the videos play together. Threads, sigh.
    But the audio that comes with the video doesn't appear to be starting at the same time. And this problem I ASSURE you i have no clue how to handle. And yes i know, the two video audios will overlap, but this a test for heavens sake!
    Anyways, heres the modified code in case it will help anyone
    import javax.swing.*;
    import javax.media.*;
    import java.awt.*;
    import javax.media.protocol.*;
    public class Video implements Runnable{
         String url;
         MediaLocator locator;
         Player player;
         JPanel panel;
         public Video (String url,JPanel panel) {
              this.url = url;
              try {
                   locator = new MediaLocator(url);
                   player = Manager.createRealizedPlayer(locator);     
                   panel.add(player.getVisualComponent());
                   player.start();
              } catch (Exception e) {
                   System.out.println("ERROR CREATING MEDIALOCATOR");
                   System.exit(-1);
         public void run() {
              try {
              Thread.sleep(100);
              } catch(Exception e) {}
         public static void main(String[]args) {
            JFrame frame = new JFrame();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel panel1 = new JPanel();
              JPanel panel2 = new JPanel();
              panel1.setPreferredSize(new Dimension(100,100));
              panel2.setPreferredSize(new Dimension(100,100));
              Thread thread1 = new Thread(new Video("file:/C:/truck1.mpg",panel1));
              Thread thread2 = new Thread(new Video("file:/C:/truck2.mpg",panel2));
              frame.getContentPane().add(panel1);
              frame.getContentPane().add(panel2);
              frame.setSize(new Dimension(500,500));     
              frame.setVisible(true);
              thread1.start();
              thread2.start();
         

  • How to connect two iMacs to the same FCE project?

    Hello All,
    Right now I have an iMac that is about 1 year old. I'm about to purchase another iMac. What I want to do is run FCE on both and work on the same video project on both. Is this possible?
    So the idea would be that I one person A could color correct and person B could edit and perform other functions on the second iMac. Can you hook them up by firewire and do this or is this beyond what you can do with FCE and two iMacs?
    Thanks for your help.
    Mike

    Hello Michael,
    First, you will need two fully licensed copies of FCE, one for each iMac. Each license allows you to install FCE on 1 Apple desktop + 1 Apple laptop as long as you own both computers and do not use FCE on both at the same time. But it *does not* allow you to install it on 2 Apple desktop computers (eg iMacs).
    Second, in order for two people on different computers to access the same project, you would have to store all the media & scratch files in a common location, and set up each copy of FCE to access the files from that location. The problems with this approach are 1) FCE cannot do this over a network, 2) you cannot connect an external FW drive to both computers at the same time, 3) FCE prefers that your FCE Project file(s) be on your system HD.
    You could use an external FW drive to store your media & scratch files; then connect the FW drive to the computer that is going to work on the project - but not to 2 computers at the same time. You will still have to copy the FCE project file between the two iMacs each time you swap from one to the other for editing.

  • "Newbie" Unable to run two actions at the same time please help

    Hello
    I'm a newbie (2 weeks) on Labview, so I hope my problem will sound easy for some of you.
    I want to read a file and at the same time get the reading from my sensors (4 sensors).
    My program is working when I do each thing in a different program but when I add them the program only read the text file and stop reading the sensor signals...I attach the program file.
    The goal is with the text file to add an exact time for each sensor signal I record.
    Is there any other possibilities to include a time with the sensors signals recorded ? I need to do this to synchronize the sensors values with CAM program.
    Thanks
    /Xavier
    Ps I used a scan rate of 12000/s but I try 1000/s
    and the sensor acquisition is still not working
    Attachments:
    test3Rdif2802.vi ‏493 KB
    readfile.txt ‏195 KB
    sensoracquisition30s.txt ‏210 KB

    from a glance at your code, it appears that you have nested a loop to read your file, inside a loop to read your sensors. this means the nested loop to read your file must finish before the outside loop to read your sensors can run through another iteration. what you want to do is separate the two loops to run independently of each other (in parallel). use a global variable to know when to stop the loop (if they need to stop at the same time) and if you need to pass data between the loops use a queue (easiest) or you can also use globals with semaphores.

Maybe you are looking for

  • HP Officejet Pro 8500A Premium scans PDFs at legal size but I want letter size

    Hi, I have an iMac with OS 10.7.5 and my Officejet Pro 8500A Premium makes scans to computer that are legal size, even tho the original is letter sized. I can't see how to change this in HP Utility. I don't have HP scanning software because I was una

  • Files dissapeared in Captivate 5.5

    I am wondering if anybody experienced the problem where suddenly the Captivate project files, .doc , .mp4 disappear after PC restart from my project folder. I rebooted my PC several times during the project but suddenly it is gone. I also work on oth

  • Printing trouble

    I'm using a Macbook running 10.4.7, and I'm having problems printing. The two printers I normally use, an HP deskjet 5550 and an HP photosmart 8150 have mysteriously disappeared from my MS Word print thingy and when I try to re-add them, I get the er

  • Datafrom different years 1 table

    Hello all, A table ('main') contains data for multiple years (2009, 2010, 2011) , department and expense. How can I duplicate in Oracle BI 11G : select a.department, a.expense, a.year,b.department, b.expense, b.year, from main a, main b where a.depar

  • Filing out Acrobat forms online?

    I came across an interactive PDF form today that allowed you to complete the form online and then print out a copy to mail. I knew you could create interactive forms, but I had no idea that this could be done. How is this enabled? http://www.kohlscor