Caching in Stateless beans?

Discussions

EJB design: Caching in Stateless beans?

  1. Caching in Stateless beans? (3 messages)

    What is more appropriate?
    1) Caching database connection as a member variable in Stateless beans or
    2) Getting a connection on a need basis and then releasing it?

    Threaded Messages (3)

  2. Caching in Stateless beans?[ Go to top ]

    Cache the DataSource Looked up from JNDI in the Stateless Session Bean and create connection on need basis and release ASAP.
  3. Caching in Stateless beans?[ Go to top ]

    This depends on your application requirement. Suppose your application has transaction then you should get the new connection for each request. If your application has no transaction then you can go with the first case. Also that your application should be used more frequently. Otherwise caching of connection is not good as per performance. Here the main thing is your connection should be used at very frequent intervals of time. Otherwise one connection will be struck at your stateless session bean.
  4. Caching in Stateless beans?[ Go to top ]

    Is you are using (1) then you will end up with transaction and connection starvation issues.

    Use (2).