0

次の方法で Web アプリケーションにスレッドを作成しています。Web アプリケーションでスレッドを作成することはおそらく正しいことではありませんが、残念ながらそれが私のアプリケーションで行われている方法です。

スレッドは、実行可能なオブジェクトに渡された同じ接続オブジェクトを使用して、ストアド プロシージャを呼び出す必要があります。しかし、エラー DSRA9110E: ステートメントが閉じられているため、プロシージャーは実行されません。断続的に「接続が閉じられています」というメッセージも表示されます。これは IBM Websphere でのみ発生し、Apache Tomcat にデプロイされた場合は問題がないことに注意してください。

スレッドが実行される可能性はありますか。つまり、persistReconcileRecord メソッドが完了する前に thread.start() が実行されます。

このステートメント/接続がクローズされた問題の原因を理解できません。この問題について何か助けていただければ幸いです。さらに情報が必要な場合は教えてください。

public class MyServiceImpl{
    private ReconDAO reconDAO = new ReconDAO();

    public String anyMethod(String infodom,ReconModel recon){

       //persistReconcileRecord is a method in DAO class.
        reconDAO.persistReconcileRecord(infodom, recon,"I");
        Connection connection=DBManager.getConnection(infodom);
        WorkerThread worker=new WorkerThread(infodom,recon.getReconciliationId(),"I",connection);
        Thread thread=new Thread(worker);
        thread.start();

        JSONObject jsonObj=new JSONObject();
        jsonObj.put("EXIST_VALIDATION", "false");
        jsonObj.put("RECONCILIATION_ID", recon.getReconciliationId());
                return jsonObj.toString();

            }

        }

    public class ReconDAO{
      public void persistReconcileRecord(String infodom,ReconModel reconModel) throws Exception{
       try{
        //This method creates a new connection and inserts records into database and then closes it.
      }catch(Exception e){

    }finally{
       closeConnection(connection);
       closePreparedStatement(pstmt);
    }

    }

public class WorkerThread implements Runnable{

    private String infodom;
    private Long reconciliationId;
    private String operation;
    private Connection connection;
    //A parameterized constructor to initialize all instance variables

    public void run(){
       //Uses the connection object from this class and then closes it in finally block
      //Calls a stored procedure
    }



}
4

1 に答える 1