Forcing a line to execute before another - how to

I am creating a Java desktop GUI application where I am accessing oracle database. Some queries take up to 1 min to return results, so I have a textbox that displays some information like "fetching data" so the user knows wats happening. I am trying to do this by
public Connection my_db_conn() {
        try {
                jTextArea1.append(getMyTime() + "\nAttempting connection to harkishora-Oracle dB....\n");
           // connect to dB statements here OR other fetch data queries
                jTextArea1.append(getMyTime() + "\nconnection established successfully\n");
        } catch (Exception e) {
            jTextArea1.append("\n--------\n" + getMyTime() + "\nUnable to connect to harkishora-Oracle dB. Probably the server is down.\n--------\n");
        return (conn);
    }the issue is before it appends the info "Attempting connection to harkishora-Oracle dB....", I mean before it visually puts the text to the textarea.....it actually executes the connection statements and after it finishes all this prints the info the screen. My idea is to force it to print the info first and then go on to connect to the dB.
any help would be appreciated.....Thanks in advance.

Yours is likely a concurrency issue -- where your database code is being called on Swing's Event Dispatch Thread (the EDT) and tying it up. Since this thread is the single thread that Swing uses for painting the GUI and interacting with the user, this effectively freezes your app until the database reading is through.
Solution: do the database work in a background thread. Please read this for details on the problem and its solution:
[Concurrency in Swing|http://java.sun.com/docs/books/tutorial/uiswing/concurrency/index.html]

Similar Messages

  • How to suspend the script be executed before Alert.show() completed?

    how to suspend the script be executed before Alert.show()
    completed?
    In a window, when users want query and display new data, they
    should be asked whether to save the old data. The
    queryAndDispleyNewData script should not be executed untile the old
    data is saved or be gived up.
    queryNewData(){
    if (Alert.show(askSaveOrNot)==YES) doSave();
    queryAndDisplyNewDate_Script;
    however, the face if the queryAndDisplyNewDate_Script is
    always executed before doSave(). how could I do?
    Any suggestion will be appreciated.

    You cannot suspend the script. Flex/ActionScript is
    event-driven. When you post a dialog box - modal or not - you
    assign event listeners to it. It is in the event listeners that you
    do whatever it is the dialog is asking - saving data back to the
    server, for example.
    Requesting and posting data to the server is event-driven
    too. If you request data from the server you must process it in an
    event handler (which includes data binding).
    If you are going to develop Flex applications you will need
    to understand event-driven programming.

  • How to delete confirmed schedule lines, without executing the ATP check?

    Sales and Distribution: Concerning ATP (product allocation)
    Situation:
    Step 1: An order is created with priority low. Quantities are confirmed for line items.
    Step 2: A second order is created with a higher priority. No confirmed quantities.
    Rescheduling program (SDV03V02) is then executed. This selects and sorts the orders in the correct order.
    The confirmed quantities for the first (low priority) order should now be freed up, to be able to allocate those quantities to the second (high priority) order.
    The problem I am facing is that the confirmed quantities are NOT released.
    We cannot use BAPI_SALESORDER_CHANGE or SD_SALESDOCUMENT_CHANGE to delete or modify the schedule lines, because these function modules execute the ATP check again. And when that happens, quantities are again confirmed and assigned.
    How can we get rid of the confirmed schedule lines, without executing the ATP check?
    Thanks,
    Edwin.

    Found a solution to the problem:
    In the Rescheduling program we export a parameter to the memory, to make it possible to delete schedule lines without executing the ATP check.
    Deleting of the schedule lines is done with a BAPI, which will call the ATP check automatically for ATP relevant materials. This we want to stop from happening (only when calling the BAPI).
    After the BAPI has been called we FREE the MEMORY ID.
    The parameter is imported again in Customer-Exit EXIT_SAPLATPC_001.
    Transaction.. SMOD
    Enhancement.. ATP00001
    Component.... EXIT_SAPLATPC_001,
    Include...... ZXATPU01.
    The customer exit is used in function AVAILABILITY_CHECK_CONTROLLER, just before calling function 'AVAILABILITY_CHECK'.
    Simply refreshing the ATP tables in the customer-exit, will prevent the ATP check from being executed (because we removed the list containing the materials for which the ATP check needs to be done). As a result, the function 'AVAILABILITY_CHECK' will not be processed.

  • Mystery! line 2 is executing before line 1

    This is such a mystery that line 2 is execute before line 1.
    please read slowly.
    Example! I have a class Payment to make a payment. I could
    Call it from 2 classes from class CustomerFrame and from
    class AllBalance. and all classes has the customers balance.
    now class Payment receives in the constructer. or an object from
    class CustomerFrame. or an object from AllBalance.
    in order to change the balance from that object.
    now after i'm inserting A payment I
    have to change the balance from the other classes. so I do A
    commit to the database from class Payment. and then I dispose the other
    classes and I create A new object from the other classes what I dispose so the is changed.
    now please look at this code. Problem with last line of code
    //class references
    CustomerFrame customerFrame;
    AllBalance allBalance;
    Object object;
    // constructer
    public Payments( Object o )
    super("Payment");
    object = o;
    if ( object instanceof AllBalance )
    allBalance = (AllBalance) object;
    else if ( object instanceof CustomerFrame )
    customerFrame = (CustomerFrame) object;
    //now after I�m inserting A payment I right
    if ( object instanceof CustomerFrame )
    customerFrame.dispose();
    customerFrame = new CustomerFrame();
    //customerFrame.setCustomer(database.findPerson(id));
    else if ( object instanceof AllBalance )
    allBalance.dispose();
    allBalance = new AllBalance( );
    Payments.this.toFront();
    Now with this last line I have problems. What?
    If the �else� statement is execute its ok the Payment frame is on top
    but if the �if � statement is execute. Problem! the Payment frame is in back,
    but its funny if I put in A JOptionPane.showMessageDialog after the last line from the
    �if� statement it works ok;
    my god what is he asking?
    If you don�t understand my question please give me A code.
    That if I change something
    from one frame it should change something from the other frame

    I can't really understand the question completely, but it sounds to me like the Frame is not coming to the front like it should. The easiest way I have found to make things act sane when a it seems like your swing method isn't doing anything is to actually invoke it through SwingUtilities.invokeLater() ... e.g. for the code you have shown
    javax.swing.SwingUtilities.invokeLater(new Runnable() {
       public void run() {
          Payments.this.toFront();
    });I don't garuantee that will work but it has seem to help me MANY times when I was extremely perplexed at what was going on. This forces your code to run on the even-dispatch thread (?I think anyways?).
    Hope this helps,
    Will

  • How to check schedule line PO text before PO saving.

    How can i check the schedule line PO text before po saving. My idea is add a trigger in user exits. but i don't know how to check this data. I can't check the table stxh or stxl because those data are stored after PO saved. I think before that the data is stored in memory or somewhere. Could you give me some advise? thanks

    Hi
    Search for a correct user exit or BADI and you can check the text of the PO schedule line
    Use the READ_TEXT fun module to fetch the text by passing the parameters OBJECT,OBJECTNAME,ID and LANGUAGE and fetch it and check it
    <b>Reward points for useful Answers</b>
    Regards
    Anji

  • Java Comiler - How to find out the Number of lines of Executable code

    Hello,
    Is there any option we have or could have to get the "Number of Lines of Executable Code" while we run the java compiler?
    Technically Java is an interpreter. So in case the term is incorrect, please excuse me.
    Since the compiler anyway traverses through the Java files, it is easy and correct to get the number from the compiler rather than having any external tool calculating the same.
    It should remove the comments, blank lines and take care of java single sentence written in multiple lines.
    Any suggestions or help is highly appreciated.
    regards,
    Sabyasachi

    How many lines of code are there in this program?
    public class sabre20110211 {public static void main(String[] args) {for (int i = 0; i < 10; i++)System.out.println(i);}}And how many in this program?
    public
            class
            sabre20110211
        public
                static
                void
                main(
                String[]
                args
            for
                    (int i = 0;
            i < 10;
            i++
                System.out.println(i);
    }

  • Does an inline view execute before the rest of the select?

    Hi,
    The O'Reilly book Mastering Oracle Sql defines an inline view simply as a
    subquery in a select FROM clause. This conforms to the definitions in
    the Oracle 9i and 10g docs.
    But unlike the Oracle docs, the O'Reilly book says the inline view is,
    like a WITH clause, executed before the rest of the query. I can't see
    how this can be done unless the inline view makes no reference to
    other tables joined in the FROM clause.
    Is there a species of inline view in 9i/10g that IS restricted as above -
    no refs to other tables in the FROM clause - and what is it called?
    Thanks for any help.
    Ken Quirici

    As explained above, Oracle can choose to merge the query if feasible to do so. Look at the two queries and their plans below. The plan in second query changes to creating a temporary VIEW since in that case, Oracle is unable to perform the merge:
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO     DEPTNO DNAME          LOC
          7782 CLARK      MANAGER         7839 09-JUN-1981       2450                    10         10 ACCOUNTING     NEW YORK
          7839 KING       PRESIDENT            17-NOV-1981       5000                    10         10 ACCOUNTING     NEW YORK
          7934 MILLER     CLERK           7782 23-JAN-1982       1300                    10         10 ACCOUNTING     NEW YORK
    3 rows selected.
    Execution Plan
    Plan hash value: 3570059291
    | Id  | Operation                    | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |                |     3 |   171 |     2   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                |                |     3 |   171 |     2   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS BY INDEX ROWID| DEPT           |     1 |    20 |     1   (0)| 00:00:01 |
    |*  3 |    INDEX UNIQUE SCAN         | PK_DEPT        |     1 |       |     0   (0)| 00:00:01 |
    |   4 |   TABLE ACCESS BY INDEX ROWID| EMP            |     3 |   111 |     1   (0)| 00:00:01 |
    |*  5 |    INDEX RANGE SCAN          | IDX_EMP_DEPTNO |     3 |       |     0   (0)| 00:00:01 |
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10 and rownum > 0) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO     DEPTNO DNAME          LOC
          7782 CLARK      MANAGER         7839 09-JUN-1981       2450                    10         10 ACCOUNTING     NEW YORK
          7839 KING       PRESIDENT            17-NOV-1981       5000                    10         10 ACCOUNTING     NEW YORK
          7934 MILLER     CLERK           7782 23-JAN-1982       1300                    10         10 ACCOUNTING     NEW YORK
    3 rows selected.
    Execution Plan
    Plan hash value: 1670713873
    | Id  | Operation                       | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                |                |     5 |   280 |     2   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                   |                |     5 |   280 |     2   (0)| 00:00:01 |
    |   2 |   VIEW                          |                |     1 |    19 |     1   (0)| 00:00:01 |
    |   3 |    COUNT                        |                |       |       |            |          |
    |*  4 |     FILTER                      |                |       |       |            |          |
    |   5 |      TABLE ACCESS BY INDEX ROWID| DEPT           |     1 |    20 |     1   (0)| 00:00:01 |
    |*  6 |       INDEX UNIQUE SCAN         | PK_DEPT        |     1 |       |     0   (0)| 00:00:01 |
    |   7 |   TABLE ACCESS BY INDEX ROWID   | EMP            |     5 |   185 |     1   (0)| 00:00:01 |
    |*  8 |    INDEX RANGE SCAN             | IDX_EMP_DEPTNO |     5 |       |     0   (0)| 00:00:01 |
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL>
    can it, in it's WHERE clause, reference other tables in the FROM clause?No. it cannot. but as said above, tha may not stop Oracle from merging the queries.
    SQL> select *
      2          from scott.emp e,
      3                  (select * from scott.dept d where d.deptno = 10 and e.sal > 1000) dd
      4  where
      5          e.deptno = dd.deptno
      6  /
                    (select * from scott.dept d where d.deptno = 10 and e.sal > 1000) dd
    ERROR at line 3:
    ORA-00904: "E"."SAL": invalid identifier
    SQL>

  • Remove forced country line in contacts

    Has anyone come across a way to remove the forced "Country" line in the iPad (and iPhone) address book? First we're force formatted into the antiquated (XXX) XXX-XXXX phone format, now it seems we're forced into adding another line to addresses that for many of us is unnecessary the vast majority of the time. I'm hoping there is a workaround.
    Even when editing the addresses, or entering them initially, via the web-interface of MobileMe without any data in the Country field, the iPad (and iPhone) adds it.
    To clarify, I am not asking how to change the country that is auto-populated (which for those needing to do this can be altered by going to Settings -> General -> International -> Region Format). I am asking how to remove any data from appearing in this line unless I specify a country. Thank you.

    If I looked in preferences I would have seen the answer - change the country!

  • Vertical Color Lines on my imported file how can i remove and edit

    Vertical Color Lines on my imported file how can i remove and edit

    If you haven't used After Effects before, you should understand that posession of a template is NO guarantee of success without prior AE knowledge.  It appears you haven't used AE before.
    The color bars indicate a missing file, and your screen shot reveals no text layers. Looking at the precomp names, opening the one called, "edit text" might be useful.
    I will guess that the following would be even more useful:
    http://blogs.adobe.com/aftereffects/2010/01/getting-started-with-after-eff.html
    Without knowledge of the AE basics, templates are pretty much useless.

  • Trigger points for 'Execute before query'  in obiee server

    Hi
    Can anybody tell me when the sql given in the 'Execute before query' ( Connection Pool and go to the Connection Scripts tab) will be executed. Is it overtimes we do a query? Can we have any control over it?
    Thanks a lot
    Regards
    Raj

    Hi,
    You might want to check the NQQuery.log to see the code that it is running before making a connection. Just to confirm that the connection pool step is working fine, could you try with a simple select statement and see that it does not error out. If it does not, you may want to revisit the procedure code again. I understand from the error that it is expecting something after the END statement (kind of weird though!!). I assume in this case, it could not parse that this is a stored procedure call itself may be. One thread I found is http://stackoverflow.com/questions/4270818/ora-06550-and-pls-00103 which you may want to look for the line break characters.
    Hope this helps.
    Thank you,
    Dhar

  • Default java / jsp file which gets executed before DAM asset rendering

    Hi,
    I have a requirement to implement access control on DAM assets on the basis of a metadata property (tags).
    Is there a default JAVA / JSP file which gets executed before rendering a DAM asset?
    If yes, how can I override it?
    If no, how can I add a new JSP / JAVA file to be executed before rendering of each DAM asset?
    Thanks in advance,
    Anurag

    Hello Anuran,
    I dont think there is any api which is executed when you rendering any DAM asset on page component because for each type of DAM asset there are different APIs available which you use the render those dam asset like "Image" class to render the image asset.
    Each dam asset also support having different rendition format and if you are interested in that then refer http://dev.day.com/docs/en/cq/current/javadoc/com/day/cq/dam/api/DamEvent.Type.html
    Please let me know if you need more information
    Thanks,
    Pawan

  • I want to use command line to execute an oracle report?

    Dear all,
    I am using Oracle Application. Does anyone know how to use command line to execute an oracle report?
    I mean execute command from client to server.
    Please advice,
    Amy
    Edited by: amychan60 on Dec 13, 2009 11:33 PM

    Hi,
    Using Oracle Application Server the standard way for a client to request a report is via a HTTP request. This doesn't really lend itself to use directly on a command line on a client however you could use the following:
    explorer "http://your_server/reports/rwservlet?report=report_name.rdf&userid=userid/password@db_sid&paramform=no&destype=FILE&desname=c:\temp\filename.pdf&desformat=pdf"
    This will load explorer and submit that URL for you and request the report. You can change the parameters depending on the report output you require.
    If you need something that is silent (ie doesn't load in explorer) you'll need to investigate other ways of submitting that URL request, perhaps using Java. You could also use SRW.run_report (Event Driven Publishing) to submit the request using SQL.
    Cheers,
    Toby.

  • [svn:bz-4.0.0_fixes] 16148: Update config testsuite on 4.0. 0_fixes branch to force kill the app server before running any tests when the app server is Tomcat .

    Revision: 16148
    Revision: 16148
    Author:   [email protected]
    Date:     2010-05-17 06:40:40 -0700 (Mon, 17 May 2010)
    Log Message:
    Update config testsuite on 4.0.0_fixes branch to force kill the app server before running any tests when the app server is Tomcat. The regression runs were hanging on this branch when going to run the config suite because the Tomcat server isn't shutting down cleanly at the end of the MXUnit run. I believe this is an issue with the version of ActiveMQ we are using. Since I don't think we want to update ActiveMQ on this branch force killing the Tomcat server will workaround the problem.
    Modified Paths:
        blazeds/branches/4.0.0_fixes/qa/apps/qa-regress/testsuites/config/build.xml

    Hi,
    Thanks for the reply. I have tried this on another machine running the same version of Blackboard. It works fine.
    Only difference is that the machine that has the JVM crash is running on Fujitsu PrimePower and the OS is Solaris 9 (but twigged for PrimePower).
    The one where it runs and starts up successfully is running on SunFire (OS is Solaris 10).
    I am wondering if there is a problem with the JVM loading required libraries because of the OS being different versions.
    Any leads on this is welcomed. Thank you.
    Regards,
    Hon Peng
    ===================
    On Fujitsu Primepower
    SunOS 5.9 Generic_118558-33 sun4us sparc FJSV,GPUS
    the Dependencies for libjvm.so are as follows:
    ===================
    bash-2.05$ ldd -r libjvm.so
    libsocket.so.1 => /usr/lib/libsocket.so.1
    libsched.so.1 => /usr/lib/libsched.so.1
    libdl.so.1 => /usr/lib/libdl.so.1
    libCrun.so.1 => /usr/lib/libCrun.so.1
    libm.so.1 => /usr/lib/libm.so.1
    libthread.so.1 => /usr/lib/libthread.so.1
    libc.so.1 => /usr/lib/libc.so.1
    libnsl.so.1 => /usr/lib/libnsl.so.1
    libmp.so.2 => /usr/lib/libmp.so.2
    /usr/platform/FJSV,GPUS/lib/libc_psr.so.1
    =====================================
    On SunFire, Sun machine
    SunOS 5.10 Generic_118833-36 sun4u sparc SUNW,Sun-Fire-280R
    the dependencies are different for the libjvm.so:
    =====================================
    bash-2.05$ ldd -r libjvm.so
    libsocket.so.1 => /lib/libsocket.so.1
    libsched.so.1 => /usr/lib/libsched.so.1
    libdl.so.1 => /lib/libdl.so.1
    libCrun.so.1 => /usr/lib/libCrun.so.1
    libm.so.1 => /lib/libm.so.1
    libthread.so.1 => /lib/libthread.so.1
    libc.so.1 => /lib/libc.so.1
    libnsl.so.1 => /lib/libnsl.so.1
    libmp.so.2 => /lib/libmp.so.2
    libmd5.so.1 => /lib/libmd5.so.1
    libscf.so.1 => /lib/libscf.so.1
    libdoor.so.1 => /lib/libdoor.so.1
    libuutil.so.1 => /lib/libuutil.so.1
    /platform/SUNW,Sun-Fire-280R/lib/libc_psr.so.1
    libm.so.2 => /lib/libm.so.2
    /platform/SUNW,Sun-Fire-280R/lib/libmd5_psr.so.1

  • Insert statement executes before If statements

    Hello All,
    I am trying to validate few fields before inserting them into table.
    for example:
    IF params('txtID') IS NULL THEN
    "SOME MSG";
    ELSIF params('txtName') IS NULL THEN
    "SOME MSG";
    END IF;
    INSERT INTO TABLE T1
    VALUES(params('txtID'),params('txtName');
    What I want to do is : I want to validate two fields before inserting.
    Can anyone help me?
    Thank you,
    H.

    It directly executes insert statement. If I delete insert, it executes that IF statement.
    It is strange.Let's be clear about this, it is not strange. Your original IF statements did execute before the INSERT but they did not raise an exception. Consequently the INSERT statement was processed. Your "SOME MSG" mechanism is obviously only triggered after the procedure completed. Walter's solution worked for you because it raise exceptions, which prevented the INSERT statement from executing.
    Anyway, it is obvious that you haven't got NOT NULL enforced on your table, which is A Bad Thing. You shoudn't be enforcing such constraints through a procedure.
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com
    Edited by: APC on Feb 3, 2009 5:48 PM
    Only because the OP edited their final post, and removed the lines I quoted.

  • Run executable before installation

    Hello all,
    I need small information. Please help me.
    In LabVIEW Installer Window at Advanced settings, we have
    Run executable at end of installation
    Run executable before uninstallation
    Is there is any option for “Run executable before installation”?
    I want to run one LabVIEW exe before installing new software (if Runtime engine is exits in deployment PC).
    Please let me know if anyone have idea.

    The NI installers don't give you a lot of control of how things are done.  Let say you want to allow you users to have a minimum, complete, or custom install of tools.  The NI installers don't have that option.
    In the past when I need more control of how installers run, and their options, I've used a couple of free tools that I've mentioned in the past.  Inno Setup, and the helper program ISTool.
    Using this method I can make an installer, that runs a different installer first, then runs the NI installer.

Maybe you are looking for