Current Position:Home > Execute one thread in background mode.

Execute one thread in background mode.

Update:10-11Source: network consolidation
Advertisement
hello ,
I have an application where the user can shows dialogs to displays, adds, modify and delete rows of one tale inside some JTextFields.
I have a problem to use this application, when one same dialog is showed more then one time....
Exactly: not problems come the first time the dialog is showed, but the second time, the time to wait because the performance is executed is very long..., and further, ....when the dialog at last was is shoved, no data of the table are in the JTextFields.
I get errors too when at last the dialog was shoved, and the errors not aways said the same reason..., but all the errors are referred to the impossibility (in the performances that followed the first) to have a suitable resultset containing the data.
Some error are "null pointer exception" to read the resultSet, other error is "Impossibils get a block in the required time" ...
I read documentation and I understand that the fault, probably, could came from the Event Dispach Thread that had the task to manage the creation of the ResultSet.
Now I am trying to solve (at this moment without success) the problem in this direction, ...as well I have not experience about to manage the use of SwingWorker class.
I should like hear what it is wrong in that I am doing...
Initially my code was this
     * Create a resultSet, for the current table       
    private void createResultSet() {
            statement = dbconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
            currentResultSet = statement.executeQuery("Select * from " + tableName);
            boolean validateState = currentResultSet.last();
            regsNmbrOnTheTable = currentResultSet.getRow();
            System.out.println("Numero attuale di records = " + regsNmbrOnTheTable);
            // here come the exception:
            // Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
        } catch (SQLException ex) {
            reportErrors.checkingSyntaxInInputTags("metodo createResultSet(): Errore nel creare il resultSet");
//            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    } // createResultSetrecently I modified it in order to put the creation of the ResultSet in background....
     * Create a resultSet, for the current table
    private void createResultSet() {
        (acquiresResultSetInBackground = new AcquiresResultSetInBackground()).execute();
        currentResultSet = acquiresResultSetInBackground.doInBackground();
    } // createResultSet
  // inner class to manage the performance in background mode.
  class AcquiresResultSetInBackground extends SwingWorker <ResultSet, Void> {
        ResultSet resultSet;
        @Override
        protected ResultSet doInBackground()  {
        try {
            statement = dbconn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
              resultSet = statement.executeQuery("Select * from " + tableName);
        } catch (SQLException ex) {
            reportErrors.checkingSyntaxInInputTags("metodo createResultSet(): Errore nel creare il resultSet");
        return resultSet;
}How I said I get again the same behavior that was before......
thank you
Regards
tonyMrsangelo

The Best Answer

Advertisement
For custom transactions you shouldn't have a problem - unless you're trying to do something that needs dialog with the presentation server.
Set an infinite loop in the custom transaction, launch your program in backround, then from Sm50, go to debug and find out what's going on.
DATA: debug.
WHILE debug IS INITIAL. " Debug from SM50 will get you here, change field DEBUG in the
ENDWHILE.               " debugger to contain 'X', and the loop will end.
Also, if your custom tx calls any standard SAP programs/FM, there is a chance that those programs work differently in background than foreground.
  • Execute one thread in background mode. Update:10-11

    hello , I have an application where the user can shows dialogs to displays, adds, modify and delete rows of one tale inside some JTextFields. I have a problem to use this application, when one same dialog is showed more then one time.... Exactly: not

  • Require Job name in SM37 while executing call transaction in background Update:10-11

    Hi all, I am executing a report program, which contains Call transaction. I have recorded properly. The recording contains background job screen also ( means a separate popup came and i gave the job name and i gave immediately ) When i execute in thi

  • BDC is not working in when executing the program in background Update:11-30

    Hi gurus, I have a problem that in BDC is not working when i'm executing the upload program in background thru scheduling(SM36) , while it works fine when i execute directly with NO screen display modeMany transactions behave differently when execute

  • Why do we need to call start() to execute a thread. Update:11-30

    hi, Why do we need to call thread.start() to execute a thread. why not just calling run(). Vjoyhi, Why do we need to call thread.start() to execute a thread. why not just calling run(). Because, start() does two things. - start a new thread of execut

  • How to run threads in background Update:11-30

    hi everyone! I need some hints on my problem! I have an application with some working threads. When the user minimizes the app the app should go to the system tray and the threads should keep working. I already know how to put an icon with popup menu

  • Executing the program in Background Update:11-30

    Hi experts i'm trying to Execute the Program in background. Given the Input and output file locations and Press F9 for process the program in background from SE38. cause i want to run my program as a batch(Background) but its not accepting. can you p

  • How to execute ME22N transaction in background. Update:11-30

    Hi experts, How to execute ME22N and ME23N in background, when execute the transaction in background, , it should generate a spool, with out any printpreview. How can we do this....? thanksHi, Write a BDC program for updation of tables for u r user-e

  • Database Alert Macros issue while executing the macros in Background Update:11-30

    Hi All, I am facing some problems while executing the Database alert macros in Background/Process Chain. There are two macros for which the problem exists. 1.Excess Projected Inventory above Max The logic here is, the alert should work for Only Fixed

  • Is ThreadPoolExecutor.execute(Runnable) thread-safe? Update:11-30

    Is ThreadPoolExecutor.execute(Runnable) thread-safe, i.e. is it safe to invoke this method from multiple threads without making any special arrangements to ensure that not more than one thread is in the execute() method of the ThreadPoolExecutor obje

  • How to execute an RFC in background Update:11-30

    Hello People! Is there a way of execute an RFC in background without broken the execution after connection timeout? I have a RFC calling another RFC in background mode but the process stops after connection timeout. As far as I know, the sap user con