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