Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8086835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:34:19+00:00 2026-06-05T18:34:19+00:00

i have developed an app which executes sql jobs. When I click on execute

  • 0

i have developed an app which executes sql jobs.
When I click on execute button the my application goes into running state and it halts untill the query is executed.

I want my app should not halt and the user should be able to enter other query and those query execution should run in background.

My question is how to run the execution of queries in background?
means when the execute button is clicked ,the remaining execution should run behind the screen.

My app is developed using struts1.3 framework.I have written the main functionality in execute() of Action Class

Code snippet of execute()

DAO dao1=new DAO();
                    System.out.println("Here...1");
                    con1=dao1.DBConnection(jndiname);
                    Statement st = con1.createStatement();
                    //status_id=1;
                    ResultSet rs = st.executeQuery(query); 
                    System.out.println("Here...2");
                    String id = Long.toString(System.currentTimeMillis());
                    //int req_id = System.currentTimeMillis();
                    String dirTree= rsBundle.getString("CSV_DIR");
                    File f=new File(dirTree);
                    String[] directories = dirTree.split("/");
                    String[] lists=f.list();

                    for (String dir : directories )
                    {
                        if (!dir.isEmpty() )
                        {
                            if (f.exists())
                            {

                                System.out.println("directory exist");
                            }
                            if (!f.exists())
                            {
                                boolean success = (new File(dirTree).mkdirs());
                                if(success)
                                {
                                System.out.println("directory created");
                                }

                            }

                            }

                            }
                    for(String s:lists)
                    {
                        System.out.println("files.." + s);
                    }
                    String csv_file_path=dirTree+"/";
                    String csv_file_name=id +".csv";
                    //writing to csv file
                    CSVWriter writer = new CSVWriter(new FileWriter(csv_file_path + csv_file_name), ',',CSVWriter.NO_QUOTE_CHARACTER);

                    writer.writeAll(rs, true);
                    writer.close();
                    //status_id=7;
                    String zip_file_path=rsBundle.getString("zip_file_path");
                    String zip_filename=id + ".zip";

                    String zip_file_pwd=rsBundle.getString("zip_file_pwd");
                    //zip file creation
                    ZipUtil.zipDirWithPassword(dirTree,  zip_file_path + zip_filename,zip_file_pwd);
                    String ftp_file_path=rsBundle.getString("ftp_file_path");
                    long zip_file_size= new File(zip_file_path + zip_filename).length();
                    System.out.println("File size..inside" + zip_file_size);
                    System.out.println("Here...3");
                    String exec_id=(String)request.getSession().getAttribute("userLoginId");
                    //int executor_id= Integer.parseInt(exec_id);
                       DateFormat dateFormat = new SimpleDateFormat("mm/dd/yyyy");
                       //get current date time with Date()
                       Date date = new Date();
                       System.out.println(dateFormat.format(date));

                    String query4 = "select executor_id,email_id from m_executor where windows_id = '" +  exec_id + "'";
                    System.out.println("Query... " + query4);
                    //int i=0;
                    iPreparedStatement4=con.prepareStatement(query4);

                    iResultSet3=iPreparedStatement4.executeQuery();
                    while(iResultSet3.next())
                    {
                        //restriction=iResultSet2.getString(1);
                        exec_email=iResultSet3.getString(2);
                        executor_id=iResultSet3.getInt(1);
                    }

                                    ValueListForExec db= new ValueListForExec();
                    String status_name="";
                    status_name=db.getStatusName(status_id);

                    if(zip_file_size <= 5242880){
                        System.out.println("send via email");
                    /*}
                    else
                    {*/
                        System.out.println("send via FTP");
                        upload.upload(host, usrname, pwd,zip_file_path + zip_filename, ftp_file_path,zip_filename);
                    }


                    String insertquery="{ call sp_process_job (?,?,?,?) }";

                    cs = con.prepareCall(insertquery.toString());
                    cs.setString(1,id);
                    cs.setString(2,host);
                    cs.setString(3,usrname);
                    cs.setString(4,pwd);


                    cs.execute();

                    con.commit();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T18:34:21+00:00Added an answer on June 5, 2026 at 6:34 pm

    You are about to enter the world of threading.

    To run a task in the background you need to start that task on a separate thread.
    If you are running in a Swing app you will need to ensure that you are not running the task on the event-dispatcher thread.

    Have a look at SwingUtilities invokeLater.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have current a developed app which I am going to submit in just
I have enrolled in the iOS developer's program. I've developed an app which I
I have developed an Android app which I want to be available both as
I have developed an application which creates an outlook application using outlook object model.
We have developed a messaging application in j2me which adds text message, gets pictures
I have developed a Cocos2d-X app with XCode which works perfectly when I launch
I have developed an app which shows the time in a full screeen. The
I have developed iPhone app which contains a 80MB audio files and 20MB images
I have developed an app which is destined for tablets in hospitals for patients
I have developed an app which uses my own custom keyboard (well, a view

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.