This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

max connections error  RSS feed

 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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.

Any clue as to why is this happening?

Thanks & Regards
 
Jeanne Boyarsky
author & internet detective
Sheriff
Posts: 37242
519
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harjinder,
I'm moving this to the EJBs forum as it has to do with CMPs.
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harjinder,

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.

 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply Alex,

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..

Any clue?!!!
 
Alex Sharkoff
Ranch Hand
Posts: 209
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Harjinder,


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?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!