This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

limit on Connections

 
Rkrishna daruri
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I wish to know whether there is any limit to the number of connections,statements,resultsets that can exist in a simple bean which is accessed by a JSP file.
Is it a good practice to initiate a connection to Database in the constructor of the class used as a bean?
Thanks in advance,
Rk
 
prashant parab
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Practically there is no limit. Therotically the limit is the amount of memory space reserved for JAVA programs. The best way to use connect objects is by using connection pool.
 
Prashanth menon
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that there is a limit that depends on the maximum open cursors possible in the database. For example Oracle.
Connection pooling is a good option.
Often I think memory leaks can create problems with the maximum limit on open cursor exceeding.
Prash
 
Michael Zalewski
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Rkrishna daruri:
Is it a good practice to initiate a connection to Database in the constructor of the class used as a bean?

Probably not if you then put the bean into a web session. However, if there is only one bean in your application, or if the bean has application scope, or if your application has only a small number of simutaneous users, it should be OK.
It's probably better practice to use connection pooling. That way, the same database connection can be used to service multiple simultaneous users. And multiple beans.
The default limit for Oracle is between 50 and 100 connections (I think). The Oracle system uses some half dozen of these connections before you ever get started. If you had a session bean which made a connection in its constructor, you would use an additional connection for every instance of this bean. When you hit the limit, your bean will throw an Exception in its constructor (which may not be a good design for a bean).
Your administrator can increase this limit to many thousands if required. But if you use connection pooling, you will be able to control the limits through your pool manager.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic