I have made stateles session beans and in those beans i am using container managed transactions for handling the transactions & stuff.. and now when i deploy my application, it works fine for a while but then it says MAX connections exceeded...
and when i changed the transactions from container managed, then everythign works fine & i dont get any error.
It sounds that the error has to do with the number of connections to the database the Container maintains in the connection pool (for db such connections are obtained through javax.sql.DataSource connection factory).
Container can be configured on a minimum and maximum number of connections to a particular database (which it maintains in the connection pool). Maximum number implies how many connections to a database can be used at the same time. Eg, if maximum number is 50 then an ejb application can use up to 50 connections at the same time. If all connections are being used and another connection needs to be obtained by the ejb application then the Container throws an error indicating that the maximum number of connections has exceeded the limit.
I see two things that can help to solve the problem
1. Ensure that all connections are closed when the bean's method is completed. (If connection is left open it never goes back to the pool and therefore the risk of running out of connections increases)
2. Increase maximum number of connections to a database the Container can maintain. One should try to work out how many transactions an application requires at any given time. It obviously depends on how the application is used (eg, how many concurrent users can there be at any given time) and how the connections are used (eg, does bean's method use one connection or it uses several connections that cannot be shared withing the same transaction). I'd like to know the magic formula on how to work this number out
Would be interesting to hear other ranchers' thoughts on this subject.
But i have checjed my code and i am closing all the connections as u said in your first approach...
and regarding the number of Db connections, i dont wanna change it as i think the default number of connections are enough for this applications...
Well i think the problem is with the Container managed transaction, when i use CM transaction in stateles session beans, then i get this problem... It might be oracle app server error or bug as well... and when i change to other transaction within stateless sesion beans.. everythign works fine..
and when i change to other transaction within stateless sesion beans.. everythign works fine..
Do you mean that when you change transaction type of your SLSB to Bean everything works OK? If this is the case then it proves that there is a problem in your application when running under container transaction management. That is what you already know
I would check that the connections to the same resource manager can be shared within the same transaction
How did you determine that the default number of transactions is enough for your application?