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
Joined: Jan 10, 2002
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.
Joined: Feb 20, 2001
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
Joined: Jun 10, 2002
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.