-
1. Re: Stateful or Stateless session bean?
manu Aug 23, 2001 11:08 AM (in response to nicolas.ocquidant)Hi,
Statefull beans are used to keep conversationnal state. Use tehm when the state changes of your bean affect subsequent business method invocations, but not when you want to cache system objects. The server keeps caches and pools for that.
If you keep Connection object open you will run out of resource and you may have difficulties with transactions.
You can save a reference on the DataSource object in a ejb, this will avoid JNDI lookups. This reference should to be transient, or set to null before passivation. You retrieve it again during activation.
If there is no conversion between the client and the bean, use a Stateless bean, and cache a DataSource reference.
Manu -
2. Re: Stateful or Stateless session bean?
nicolas.ocquidant Aug 23, 2001 11:19 AM (in response to nicolas.ocquidant)Ok, that's what i've done (with stateless session bean).
In the method setSessionContext(), i get the DataSource and the Connection.
In the method ejbRemove(), i close the connection to the database. Do i need to set the DataSource variable to null?
thanks a lot
Nicolas -
3. Re: Stateful or Stateless session bean?
davidjencks Aug 23, 2001 2:02 PM (in response to nicolas.ocquidant)I dont think this is what was advised, and wont work.
cache the Datasource, and set it to null on passivate,
but _dont cache the connection_. Get the connection within each transaction or it will not be enrolled in the transaction. Close it before the end of the transaction or it will not be returned to the pool and may mess up transaction handling