3 Replies Latest reply on Jul 21, 2011 6:23 AM by ujwallshetty

    Connection handle has been closed and is unusable

    wil

       

      "wil@jboss" wrote:
      "Connection handle has been closed and is unusable".
      Using JBoss3.0.4. Is it possible that jboss closes an 'Idle timed-out' connection while it's actually still in use ?


        • 1. Re: Connection handle has been closed and is unusable
          wil

           

          "wil@jboss" wrote:
          Hi,

          Solved it myself. It's a thread problem. My javaclass, which contains de sql statement (DAO), was simultaneous used by concurrent thread. Still no problem, but i noticed that i cached the current connection, so: thread 1 opened connection A (current connection = A); thread 2 opened connection B (current connection became B). Thread 1 was done with the work en closed the current connection, which is connection B ! Thread 2 tried to close 'his' current connection, which is also connection B and that one was already closed !! So "Connection handle has been closed and is unusable" really was the case there. Notice that connection A is this case is still open !
          Solution: i've changed the method signature of my DAO's public method and added the keyword 'synchronized'. Case solved.

          Hopes this helps anymore.
          bye


          • 2. Re: Connection handle has been closed and is unusable
            milowe

             

            "milowe" wrote:
            You should avoid 'synchronized' to not block EJB threads as mentioned in the spec.


            • 3. Re: Connection handle has been closed and is unusable
              ujwallshetty

              If we do not use 'synchronized' then what is the other possible option to avoid "Connection has been closed" ?