File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes limit on Connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "limit on Connections" Watch "limit on Connections" New topic

limit on Connections

Rkrishna daruri

Joined: Jun 05, 2002
Posts: 4
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,
prashant parab

Joined: Jan 10, 2002
Posts: 17
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

Joined: Feb 20, 2001
Posts: 65
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.
Michael Zalewski
Ranch Hand

Joined: Jun 10, 2002
Posts: 30
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.
I agree. Here's the link:
subject: limit on Connections
jQuery in Action, 3rd edition