I assume you are talking about stateless session beans. Although it is surprising that JBoss gives warnings about the resource use in your implementation, it is not unexpected. It is hinting that you are implementing a potential scalability problem.
A pooled database connection is a scarce resource. We pool connections so that many EJBs in the container can share the connection. The idea is to use the connection for only as long as we need to send or receive data to the datasource, performing our work as quickly as possible. When we have finished with the connection, we return it to the pool so other EJBs can use the resource - when you close a connection obtained from a DataSource, it returns the connection to the pool rather than closing the physical connection to the database (or to whatever you are connecting).
In your case, you allocate a datasource connection to the stateless session bean for the lifetime of that instance (which can be a very long time). A stateless session bean is like a pooled connection, the instance is continually recycled.
Suppose you have an application load that requires a constant fifteen instances of a particular stateless session bean. This locks in fifteen database connections purely for the use of these bean instances. Even when the beans are idle (not doing any work), no other EJB in the container can use the connections because your fifteen beans never release the connection back to the pool.
If you want a dedicated connection for the instance lifetime of your EJB, you may as well implement a direct connection to the database rather than using a pooled connection. But this is not the most efficient use of resources.
Thank you for your reply.
I think you answered my question. I don't want dedicated connection kept open alive for the lifetime of my session bean.
If a call to close( ) on a datasource connection results in that connection being returned to pool
that is perfectly what I want
( I was just making sure that JBOSS does that )
Yes. That is right. But I made a mistake in not emphasising that you should not allocate the connection at ejbCreate for a stateless session bean as this means you allocate the connection for a very long time if you don't close it before you leave a method.
Only get the connection in the method of the stateless session bean and release it before you leave the method. It is also best practice to hold the connection for as short a time as possible within the method.
See this thread: http://www.jboss.org/modules/bb/index.html?module=bb&op=viewtopic&t=
Well, I have a doubt in this regard - is there any means of finding in the jboss 3.0.7 server side and not in the Oracle 8 database server side,
how many connections are there in the pool,
how many connections are in use and
how many connections are being returned at a given point of time?