3 Replies Latest reply on Mar 6, 2007 6:56 AM by fhh

    Database Connection Pooling?

    Matt Johnston Newbie

      Really simple question, how do I setup database connection pooling in JBoss? Is it installed by default?

      I am currently using EJB3 to access a datasource defined through jboss. I am accessing the database through:

      private EntityManager em;
      Object obj = em.find(MyClass.class, id)

      All my code works correctly, I just want to understand how the database connections are pooled. Is there anything else I need to change in my EJB3 to take advantage of the connection pooling?


        • 1. Re: Database Connection Pooling?
          Weston M. Price Master

          Use of a *-ds.xml file automatically includes JDBC connection pooling via JBossJCA. Your all set.

          • 2. Re: Database Connection Pooling?
            Matt Johnston Newbie

            I am using a *-ds.xml, so that is good, but I still don't think my pooling is working. I am stress testing my webapp. Just for kicks, I set my Postgres server to only accept a maximum of 20 connections.

            I created a stress test to have 50 concurrent users. After the test gets running, I get an error:

            Could not create connection; - nested throwable: (org.postgresql.util.PSQLException: FATAL: sorry, too many clients already)

            Shouldn't the connection pool start to queue these connections instead of throwing an exception?

            • 3. Re: Database Connection Pooling?
              fhh Expert

              Not if you do have 50 concurrent users. The connection is only returned to the pool when you close it. This obviuosly means it is not used anymore.

              Connection pooling will not give you any kind of multiplexing of database access. This is not possible due to the fact that database transactions are bound to a certein connection.