4 Replies Latest reply on May 20, 2002 8:39 AM by hamish

    De-Allocating Connections

    hamish

      To get a connection from a connection pool, you call ConnectionManager.allocateConnection() but what is the best way to return a connection to the pool.

      My connections are all the same so can be taken and returned to the pool without any state problems. As the connections to the legacy system are limited, I want to make the pool size as small as possible.

      Does anyone have any creative ideas?

        • 1. Re: De-Allocating Connections
          davidjencks

          Actually you will only call cm.allocateConnection if you are the connection factory (or the person writing the connection factory). A client will never call this method: they will use a connection factory
          cf.getConnection() or something equivalent.

          All you can do is conn.close(). If you aren't using local tx, this will definitely put the connection back in the pool. If you are using local tx, it will put the connection in the pool once the tx (if any) is over.

          The jboss 3 rc1/2 connection manager does a lot of work so even if you hold a connection over a method boundary it is returned to the pool if possible, and your connection handle reconnected when you get back to the same object. I can't recommend useing this however, I think explictly acquiring and closing your connection handles in the smallest possible scope is the best idea.

          • 2. Re: De-Allocating Connections
            hamish

            Will follow instructions...

            I was looking for the jar containing PoolEventListener in RC2 and could not find anything. I copied jboss-pool.jar from RC1.

            Is this the latest version?

            • 3. Re: De-Allocating Connections
              davidjencks

              NOOOOOOO!!!!!!

              rc2 includes a complete reimplementation of the jca framework. I did this because I couldn't fix the problems and limitations of the earlier implementation. Please don't bring back my nightmares!

              What are you trying to do that you are looking at these internals?

              • 4. Re: De-Allocating Connections
                hamish

                Oops, spotted the mistake. I was using the example from RC1 which used PoolEvent.

                The new example seems more straight forward.

                thank you