General J2EE: Application makes too many database connections

  1. I am working on a J2EE application with 12 entity beans implementing with BMP. On running the application I am getting the following error (from server log):

    Failed to obtain/create connection. Reason : No available resource. Wait-time expired.|#]

    This is inspite of the fact that every connection created is definitely closed in the code.

    Could you help me out with this problem?

  2. what is your poolsize? I'm assuming you're using a JDBC pool of some sort, if you have it set too low, it might cause problems. Also, 12 Entity Beans, meaning 12 types, or 12 instances? Lastly, how does your JDBC pool handle multiple requests within the same transaction? If it does not provide transaction-instancing, then potentially it will give you x different connections for x requests even within the same transaction, asking for 1 more than the poolsize will cause it to wait (on itself!) because the pool is too small.