1 Reply Latest reply on Oct 8, 2007 8:58 AM by Eric Brennan

    Questions about database connections between portlets

    alex chen Newbie

      Currently, I am trying to find out how the portlets can share database connections among them. However, I could not get any information from the documentation, hopefully I can get some here.

      The scenario is that we use dbcp to manage our db connection pool. And I guess that each portlet instance might consume a db connection, so, if a page has 10 portlets, that means 10 db connections will be used. Then what else if thousand of people visit this page, 10 times db connections will be consumed, this is horrible. Therefore, I am wondering how the db connections can be share among the portlet instances.

      I read some article saying to use the datasource should be a good idea, however, to remain using dbcp is ideally first place in our consideration.

      So any comment is appreciated:)

        • 1. Re: Questions about database connections between portlets
          Eric Brennan Newbie

          This might be just one of those "Any comments" as I am still learning this stuff also.

          A couple things about database connections.
          1. JBoss AS and Portal uses Hibernate for there connections and it looks like this technology is making good progress in the development world. Hibernate and other similar technologies (toplink) do the db connections for you. They set these connections into a pool and hand them out to the portlet as needed. Once the request is finished, it is returned to the pool. You should be closing the connection as soon load the data (a few milliseconds).

          2. I don't know how customized each users portal will be but you can increase efficiency by caching the data. You should be using enity beans to load the items from the database. It you make the bean global you should able to share it across multiple users.

          Hope this puts you in the right direction.