7 Replies Latest reply on Nov 11, 2001 12:02 PM by menggb

    Releasing connection of entity beans

    larry054

      I know this is a dumb question, but I can't find the answer. I have a stateless session bean which reads properties from several BMP entity beans. After I call this session bean a few times I have around 100 unused connections, which stick around until garbage collection. How can I force jboss to release the connections as soon as I read the properties?

        • 1. Re: Releasing connection of entity beans
          larry054

          I forgot to mention: jboss 2.4.0, Oracle 8.1.7, Type 4 JDBC driver, Win NT4 SP6.

          • 2. Re: Releasing connection of entity beans
            p_d_austin

            This is the purpose of connection pools, the underlying connections stay areound and a reused between method calls. This give much greater performance as opening connections takes a lot of time.

            What you can do tho to reduce the length of time the connections are held for is to enable the idle timeout on the datasource and set the timout to a value suitable for your application.

            The documentation can be found at http://www.jboss.org/documentation/HTML/ch04s07.html .

            The properties you need to set are 'IdleTimeoutEnabled' and 'IdleTimeout'.

            Paul

            • 3. Re: Releasing connection of entity beans
              larry054

              p_d_austin,

              Thank you for the reply, but I guess I didn't make myself clear. I understand the point about connection pools and I didn't expect the connection object to go away. The problem is that the Oracle server is showing the connections open even after the stateless session bean is history. After a few runs, I am out of connections in the pool and the bean fails.

              I have reduced the time between garbage collections to get around this problem, but it seems there should be a way to force the connections to close immediately. Thanks for the help.

              • 4. Re: Releasing connection of entity beans
                larry054

                p_d_autstin,

                I just read your answer again and maybe I am still misunderstanding the purpose of the pool. If the connections are supposed to stay open, then maybe the problem is that jboss isn't reusing them properly. The session bean should not fail for lack of available connections if there are 100 of them.

                • 5. Re: Releasing connection of entity beans
                  p_d_austin

                  Are you closing the connections before you exit each method call. For any type of bean you should get a new connection from the pool and then close the connection (and any result sets and statements) before you exit from the method.

                  Paul

                  • 6. Re: Releasing connection of entity beans
                    larry054

                    Duh, I looked at my entity beans again and they close connection only in unsetEntityContext(). Your explanation makes sense to me suddenly.

                    Thanks.

                    • 7. Re: Releasing connection of entity beans
                      menggb

                      Hi,
                      Did you get your problem fixed?
                      I saw the similar problem with my stateless session bean.

                      Jack